[ quantlib-Bugs-938879 ] divide by zero in impliedVolatility()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ quantlib-Bugs-938879 ] divide by zero in impliedVolatility()

SourceForge.net
Bugs item #938879, was opened at 2004-04-20 14:26
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=938879&group_id=12740

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: divide by zero in impliedVolatility()

Initial Comment:
/*
SingleAssetOption::impliedVolatility() fails because of a
divide by zero in EuropeanOption::D1()
version 0.3.4

Test function: QL_tAmericanOptionImpliedVolatility()
*/

void QL_tAmericanOptionImpliedVolatility() {
        FdAmericanOption AO = FdAmericanOption(
                        Option::Call,
                        100.0, //underlying,
                        100.0, //strike,
                        .01,   //dividendYield,
                        .03,   //riskFreeRate,
                        .50,   //maturity,
                        .40,   //volatility,
                        150,   //timeSteps,
                        151    //gridPoints
                );

        double impliedVol = AO.impliedVolatility(11.10);
        printf("impliedVol=%f\n", impliedVol);

  }

/*
Call stack:

QuantLib::EuropeanOption::standardDeviation() line 116
QuantLib::EuropeanOption::D1() line 125 + 42 bytes
QuantLib::EuropeanOption::alpha() line 78 + 8 bytes
QuantLib::EuropeanOption::value() line 58 + 25 bytes
QuantLib::FdStepConditionOption::calculate() line 66 +
59 bytes
QuantLib::FdBsmOption::value() line 37 + 13 bytes
QuantLib::SingleAssetOption::VolatilityFunction::operator
()(double 0.00000000000000) line 124 + 24 bytes
QuantLib::Solver1D<QuantLib::Brent>::solve(const
QuantLib::SingleAssetOption::VolatilityFunction & {...},
double 0.00010000000000000, double
0.40000000000000, double 0.00000000000000, double
4.0000000000000) line 173 + 19 bytes
QuantLib::SingleAssetOption::impliedVolatility(double
11.100000000000, double 0.00010000000000000,
unsigned int 100, double 0.00000000000000, double
4.0000000000000) line 175 + 50 bytes
QL_tAmericanOptionImpliedVolatility() line 25 + 44 bytes

Divide by zero in EuropeanOption::D1() because
standardDeviation()==volatility_== 0

Definitions of the two member functions in
european_option.hpp:

    inline double EuropeanOption::standardDeviation()
const {
        if (standardDeviation_==Null<double>())
            standardDeviation_ = volatility_*QL_SQRT
(residualTime_);
        return standardDeviation_;
    }

    inline double EuropeanOption::D1() const {
        if (D1_==Null<double>())
            D1_ = QL_LOG(underlying_/payoff_.strike
())/standardDeviation() +
                standardDeviation()/2.0 +
                (riskFreeRate_ - dividendYield_) *
                residualTime_/standardDeviation();
        return D1_;
    }
 
[hidden email]
*/

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=938879&group_id=12740