1

我正在使用 QLNet 进行美式期权定价,但它不起作用。我已经在Quantlib 论坛上发布了我的问题

我的代码:

 todaysDate & settlementdate = 2012-12-18, maturity = 2013-01-18,

 Calendar calendar = new TARGET();

 Settings.setEvaluationDate(TodaysDate);
 DayCounter dayCounter = new Actual365Fixed();

 Handle<Quote> underlyingH = new Handle<Quote>(new SimpleQuote(100));
 var flatTermStructure = new Handle<YieldTermStructure>(new FlatForward(SettlementDate, 0.08, dayCounter));
 var flatDividendTS = new Handle<YieldTermStructure>(new FlatForward(SettlementDate, 0, dayCounter));
 var flatVolTS = new Handle<BlackVolTermStructure>(new BlackConstantVol(SettlementDate, calendar, 0.2, dayCounter));
 StrikedTypePayoff payoff = new PlainVanillaPayoff(Call, 101);
 var bsmProcess = new BlackScholesMertonProcess(underlyingH, flatDividendTS, flatTermStructure, flatVolTS);

 Exercise exerciseEngine = exerciseEngine = new AmericanExercise(SettlementDate, Maturity); 
 VanillaOption optionEngine = new VanillaOption(payoff, exerciseEngine); 

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

 //error:
 optionEngine.impliedVolatility(optionEngine.NPV(), bsmProcess, 1.0e-4, 100, 1.0e-7, 4.0);

标的 = 100, k=101, i=0.08, vol=0.2,div=0, todaysDate & 结算日期 = 2012-12-18, 到期 = 2013-01-18,

VanillaOption.cs中,Exercise.Type.American 的 case 代码被取消注释;

错误消息是:已添加具有相同键的项目。在 FDStepConditionEngine.cs 的第 111 行 (results.additionalResults.Add priceCurve, prices_ )

感谢您的帮助。

4

0 回答 0