http://quantlib.414.s1.nabble.com/Re-European-option-validation-tp13880p13881.html
I've tried the thing in QuantLib via Python and I get 12.6127. How
the correct time. What date do you get?
> I am new to Quantlib code base, but I have a basic question,
>
> I tried to calculate a basic European option using the below but having
> difficulty to validate the results against my spreadsheet
>
> [Call] = blsprice(100, 97, 0.1, 0.25, 0.5) returns a Call price of $12.61
> via spreadsheet
>
>
> but, via Quantlib I am getting value $10.77
>
>
> can you advice,
>
> I hope you don't mind that I posted the code below,
>
> QuantLib::Option::Type type(QuantLib::Option::Call);
> QuantLib::Real stock = 100;
> QuantLib::Real strike = 97;
> QuantLib::Real time = 0.25;
> QuantLib::Spread dividendYield = 0.00;
> QuantLib::Rate riskFreeRate = 0.1;
> QuantLib::Volatility volatility = 0.5;
>
> QuantLib::DayCounter dc = QuantLib::Actual360();
> QuantLib::Date today = QuantLib::Date::todaysDate();
>
> boost::shared_ptr<QuantLib::SimpleQuote> spot(new
> QuantLib::SimpleQuote(0.0));
> boost::shared_ptr<QuantLib::SimpleQuote> qRate(new
> QuantLib::SimpleQuote(0.0));
> boost::shared_ptr<QuantLib::YieldTermStructure> qTS = flatRate(today, qRate,
> dc);
> boost::shared_ptr<QuantLib::SimpleQuote> rRate(new
> QuantLib::SimpleQuote(0.0));
> boost::shared_ptr<QuantLib::YieldTermStructure> rTS = flatRate(today, rRate,
> dc);
> boost::shared_ptr<QuantLib::SimpleQuote> vol(new
> QuantLib::SimpleQuote(0.0));
> boost::shared_ptr<QuantLib::BlackVolTermStructure> volTS = flatVol(today,
> vol, dc);
>
> boost::shared_ptr<QuantLib::StrikedTypePayoff> payoff1(new
> QuantLib::PlainVanillaPayoff(type, strike));
> QuantLib::Date exDate = today + timeToDays(time);
>
> boost::shared_ptr<QuantLib::Exercise> exercise(new
> QuantLib::EuropeanExercise(exDate));
>
> spot ->setValue(strike);
> qRate->setValue(dividendYield);
> rRate->setValue(riskFreeRate);
> vol ->setValue(volatility);
>
> boost::shared_ptr<QuantLib::BlackScholesMertonProcess> stochProcess(new
>
> QuantLib::BlackScholesMertonProcess(QuantLib::Handle<QuantLib::Quote>(spot),
>
> QuantLib::Handle<QuantLib::YieldTermStructure>(qTS),
>
> QuantLib::Handle<QuantLib::YieldTermStructure>(rTS),
>
> QuantLib::Handle<QuantLib::BlackVolTermStructure>(volTS)));
> boost::shared_ptr<QuantLib::PricingEngine> engine(
> new
> QuantLib::AnalyticEuropeanEngine(stochProcess));
>
> QuantLib::EuropeanOption option(payoff1, exercise);
> option.setPricingEngine(engine);
>
> QuantLib::Real calculated = option.NPV();
>
> .............................
>
> boost::shared_ptr<QuantLib::YieldTermStructure>
> flatRate(const QuantLib::Date& today,
> const boost::shared_ptr<QuantLib::Quote>& forward,
> const QuantLib::DayCounter& dc) {
> return boost::shared_ptr<QuantLib::YieldTermStructure>(
> new QuantLib::FlatForward(today,
> QuantLib::Handle<QuantLib::Quote>(forward), dc));
> }
>
> Regards
> Ray
>
>
> ------------------------------------------------------------------------------
> Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
> and more. Get SQL Server skills now (including 2012) with LearnDevNow -
> 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
> SALE $99.99 this month only - learn more at:
>
http://p.sf.net/sfu/learnmore_122512> _______________________________________________
> QuantLib-dev mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/quantlib-dev>
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.