|
From: Mohammad Shoja-t. <msh...@gm...> - 2022-03-08 14:26:29
|
Hi,
Answering my own question here as I found out the reason;
inside the loop i need to re-set rTS (i'm a bit surprised i must say as its
flat rate and I thought should extrapolate correctly), and also reset
stochProcess and also re-set engine.
On Tue, Mar 8, 2022 at 12:20 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
>
--
Mohammad Shojatalab
|