Re: Implied Volatility

Posted by xnb on
URL: http://quantlib.414.s1.nabble.com/Implied-Volatility-tp7280p13812.html

I face this problem too, any one have idea? thx


my code:

Exercise exerciseEngine = new AmericanExercise(SettlementDate, Maturity);

VanillaOption optionEngine = new VanillaOption(payoff, exerciseEngine);

optionEngine.setPricingEngine(new BinomialVanillaEngine<CoxRossRubinstein>(bsmProcess, timeSteps));

optionEngine.impliedVolatility(targetValue, bsmProcess, accuracy, maxEvaluations, minVol, maxVol);


underlying = 100,
k=101,
i=0.08,
vol=0.2,
div=0,
todaysDate & settlementdate = 2012-12-18,
maturity = 2013-01-18,
int timeSteps = 801;
double accuracy = 1.0e-4;
int maxEvaluations = 100;
double minVol = 1.0e-7;
double maxVol = 4.0;
double targetValue = optionEngine .NPV();


In **VanillaOption.cs**, the code of case Exercise.Type.American is uncomment;

The error message is: **An item with the same key has already been added**.
at line 111 (results.additionalResults.Add priceCurve, prices_) in **FDStepConditionEngine.cs**

Thanks for kindly help.