Bugs item #545734, was opened at 2002-04-18 10:17
You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=112740&aid=545734&group_id=12740 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: impliedVolatility when exdivdate==today Initial Comment: FdDividendAmericanOption::impliedVolatility fails, printing "out of memory", if the first exdividend date is zero, i.e. today. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2002-04-18 10:23 Message: Logged In: NO This is a program that shows the failure. I tried to add it as attachment, but that didn't work. #include <ql/quantlib.hpp> using namespace QuantLib; using DayCounters::Actual365; using QuantLib::Pricers::FdDividendAmericanOption; using QuantLib::Pricers::FdAmericanOption; int main(int argc, char* argv[]) { try { double underlying = 100; double strike = 100; // at the money Rate riskFreeRate = 0.0; // 5% double volatility = 0.20; // 20% Actual365 dayCounter; Date today(Day(12), Month(4), Year(2002)); Date expiration(Day(13), Month(5), Year(2002)); Time maturity = dayCounter.yearFraction(today, expiration); std::vector<Time> dividendList; dividendList.push_back(2.0); double totalDiv = 0.0; for (int i=0; i<dividendList.size(); ++i) { totalDiv += dividendList[i]; } Spread dividendYield = totalDiv/(underlying*maturity); Size timeSteps=100, assetSteps = 100; FdAmericanOption myAmericanOption(Option::Call, underlying, strike, dividendYield, riskFreeRate, maturity, volatility, timeSteps, assetSteps); double myAmericanOptionValue = myAmericanOption.value(); std::cerr << "maturity=" << maturity << " underlying=" << underlying << " strike=" << strike << " riskFreeRate=" << riskFreeRate << " volatility=" << volatility << " dividendYield=" << dividendYield << " contDiv=" << myAmericanOptionValue << std::endl; for (Date exdivdate=expiration; exdivdate>=today; exdivdate--) { // std::cerr << exdivdate << '\n'; std::vector<Time> exdivtimeList; exdivtimeList.push_back(dayCounter.yearFraction (today, exdivdate)); FdDividendAmericanOption myDividendAmericanOption (Option::Call, underlying, strike, 0.0, riskFreeRate, maturity, volatility, dividendList, exdivtimeList, timeSteps, assetSteps); double impliedVol = myDividendAmericanOption.impliedVolatility (myAmericanOptionValue); std::cout << exdivdate << ' ' << 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; } } ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=112740&aid=545734&group_id=12740 |
Free forum by Nabble | Edit this page |