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]]
发送时间: 2015年5月12日 6:20
收件人: [hidden email]
主题: [Quantlib-dev] QuantLib Solver
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
Free forum by Nabble | Disable Popup Ads | Edit this page |