QuantLib Developers,
Reference http://quantlib.org/slides/dima-ql-intro-2.pdf, page 23
In Dimitri Reiswich's QuantLib Solver example, he sets up a boost function and binds this to his function impliedVolProblem() which returns the calculation of the Black Scholes Option Price - price.
Are the following two steps required, or is there a way to refactor and simplify the code and use a function pointer directly in the QuantLib Solver.solve method without having to use the boost::function and boost::bind?
// Step 1 - Setup a boost function boost::function < Real(Volatility) > VolatilityFunc ;
// Step 2 - Bind the boost function to all market parameters, keep volatility as variant VolatilityFunc = boost::bind(&impliedVolatilityProblem, spot, strikeprice, rd, rf, _1, tau, phi, price);
Real res1 = bisectionSolver.solve(VolatilityFunc, accuracy, guess, min, max);
Very best regards Nigel Sperinck ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Nigel, Of cause it could. If you look at the implementation of the solver, the solve method’s first parameter is marked as template. You only need to make sure the VolatilityFunc accept a double and return a double. Regards, Cheng 发件人: Nigel Sperinck [mailto:[hidden email]] QuantLib Developers, Reference http://quantlib.org/slides/dima-ql-intro-2.pdf, page 23 In Dimitri Reiswich's QuantLib Solver example, he sets up a boost function and binds this to his function impliedVolProblem() which returns the calculation of the Black Scholes Option Price - price. Are the following two steps required, or is there a way to refactor and simplify the code and use a function pointer directly in the QuantLib Solver.solve method without having to use the boost::function and boost::bind? // Step 1 - Setup a boost function boost::function < Real(Volatility) > VolatilityFunc ; // Step 2 - Bind the boost function to all market parameters, keep volatility as variant VolatilityFunc = boost::bind(&impliedVolatilityProblem, spot, strikeprice, rd, rf, _1, tau, phi, price); Real res1 = bisectionSolver.solve(VolatilityFunc, accuracy, guess, min, max); Very best regards Nigel Sperinck ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |