|
From: Mohammad Shoja-t. <msh...@gm...> - 2022-03-08 12:20:40
|
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
|