Error with old-style implied vol
Posted by Dirk Eddelbuettel on Nov 26, 2003; 8:30pm
URL: http://quantlib.414.s1.nabble.com/Error-with-old-style-implied-vol-tp10464.html
In the process of updating RQuantLib to 0.3.4, I found that my wrappers
around European and American implied vol no longer work. [ That I found that
is a good thing; R stronly encourages a manual page for every function.
These manual pages usually have examples, and during the 'make check' phase
all of the available examples are run. Quite nice. ]
I do know that I'll have to convert to the new prices one day anyway, but is
there a shortcut to keep the current alive while I prepare one based on the
new pricing engines?
I include a simple stand-alone below. It builds fine, compute the NPV of an
option (just to show that it links right etc pp) but abort on implied vol.
CHROOT edd@chibud:~/src/progs/C++$ g++ -Wall -o test_ql_impliedvol
test_ql_impliedvol.cc -lQuantLib
CHROOT edd@chibud:~/src/progs/C++$ ./test_ql_impliedvol
Value: 5.81756
Aborted
Here is the short program:
// implied vol in RQuantLib-0.1.7 blows up with QL 0.3.4
#include <ql/quantlib.hpp>
#include <iostream>
using namespace QuantLib;
using QuantLib::Pricers::EuropeanOption;
int main(void) {
double underlying = 100;
double strike = 100;
double dividendYield = 0.02;
double riskFreeRate = 0.03;
double maturity = 0.5;
double volatility = 0.2;
Option::Type optionType = Option::Call;
EuropeanOption EO = EuropeanOption(optionType, underlying, strike,
dividendYield, riskFreeRate, maturity,
volatility);
std::cout << "Value: " << EO.value() << std::endl;
double impliedVol = EO.impliedVolatility(EO.value()+0.1);
std::cout << "Implied:" << impliedVol << std::endl;
exit(0);
}
Thanks in advance for any insights.
Dirk
--
Those are my principles, and if you don't like them... well, I have others.
-- Groucho Marx