Hi,
I've just learned about QuantLib from Dirk's posting to r-help (thank you Dirk!) and looked through the info available from the home page. I understand that the project is in early stages of development and so the documentation is not complete. Before I go and read the source code I wonder if someone can save me time and tell how easy/difficult it is with QuantLib to compute implied volatility of an American option on a divident paying stock (either cash or stock). Thanks, Vadim -------------------------------------------------- DISCLAIMER This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Knight Trading Group may, at its discretion, monitor and review the content of all e-mail communications. |
At 02:43 PM 2/26/02 -0600, Vadim Ogranovich wrote:
>Before I go and read the source code I wonder >if someone can save me time and tell how easy/difficult it is with QuantLib >to compute implied volatility of an American option on a divident paying >stock (either cash or stock). Below I give you an example with continuous dividends. The class FdDividendAmericanOption handle discrete dividends hope this helps ciao -- Nando ============================== #include <ql/quantlib.hpp> using namespace QuantLib; using QuantLib::Pricers::FdAmericanOption; int main(int argc, char* argv[]) { try { // our option double underlying = 102; double strike = 100; // at the money Spread dividendYield = 0.03; // no dividends Rate riskFreeRate = 0.05; // 5% Time maturity = 0.25; // 3 months double volatility = 0.20; // 20% std::cout << "Time to maturity = " << maturity << std::endl; std::cout << "Underlying price = " << underlying << std::endl; std::cout << "Strike = " << strike << std::endl; std::cout << "Risk-free interest rate = " << riskFreeRate << std::endl; std::cout << "Volatility = " << volatility << std::endl; std::cout << std::endl; Size timeSteps=100, assetSteps = 20; FdAmericanOption myAmericanOption(Option::Call, underlying, strike, dividendYield, riskFreeRate, maturity, volatility, timeSteps, assetSteps); double value = myAmericanOption.value(); std::cout << "vol " << DoubleFormatter::toString(volatility, 6) << " value " << DoubleFormatter::toString(value, 6) << std::endl; double impliedVol = myAmericanOption.impliedVolatility(value*1.1); std::cout << "a value of " << DoubleFormatter::toString(value*1.1, 6) << " implies a vol " << DoubleFormatter::toString(impliedVol, 6) << std::endl; return 0; } catch (std::exception& e) { std::cout << e.what() << std::endl; return 1; } catch (...) { std::cout << "unknown error" << std::endl; return 1; } } |
Free forum by Nabble | Edit this page |