|
From: Luigi B. <lui...@gm...> - 2022-03-08 16:04:59
|
Hi Mohammad — how did you create the curves in the process (spot etc)? Is
it possible that they have a fixed reference date?
Luigi
On Tue, Mar 8, 2022 at 1:24 PM Mohammad Shoja-talab <msh...@gm...>
wrote:
> Hi,
>
> I'm trying to re-evaluate an option with different today's date and a
> fixed maturity date, in a loop, but I keep getting the same result as if
> today's date doesn't get updated to new value.
>
> my code roughly looks like this:
>
>
>
> boost::shared_ptr<QuantLib::StrikedTypePayoff> payoff(new
> PlainVanillaPayoff(QuantLib::Option::Call, faceValue));
>
> 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 =
>
>
> QuantLib::MakeMCDiscreteArithmeticAPEngine<QuantLib::LowDiscrepancy>(stochProcess)
>
> .withSamples(4095)
>
> .withControlVariate(true);
>
>
>
> boost::shared_ptr<QuantLib::Exercise> exercise(new
> QuantLib::EuropeanExercise(maturityDate));
>
>
>
> for (int i = 0; i <= 4; ++i)
>
> {
>
> auto tDay = QuantLib::Date(1, QuantLib::March, 2022 + i);
>
> QuantLib::Settings::instance().evaluationDate() = tDay;
>
>
>
> QuantLib::DiscreteAveragingAsianOption option(averageType, runningSum,
> pastFixings, fixingDates,
>
> payoff, exercise);
>
>
>
> option.setPricingEngine(engine);
>
> option.recalculate(); // even this doesn't help, or resetting of
> engine and stochProcess
>
>
>
> QuantLib::Real quantLibValue = option.NPV();
>
>
>
> BOOST_CHECK_CLOSE(expectedValue, quantLibValue, 0.3); // error less
> than 0.3%
>
> }
>
>
>
> Any idea what I'm doing wrong please?
>
>
> --
> Mohammad Shojatalab
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|