|
From: Mohammad Shoja-t. <msh...@gm...> - 2022-03-09 09:26:39
|
Hi Luigi,
Thank you very much. That (moving curves) did the trick.
Kind regards,
Mo
On Tue, 8 Mar 2022, 16:07 Luigi Ballabio, <lui...@gm...> wrote:
> Using moving curves should work, too, without having to reset anything;
> that is, instead of using FlatForward(referenceDate, rate, dayCount), use
> FlatForward(0, calendar, rate, dayCount) to create a curve that resets
> automatically when the evaluation date changes. 0 as the first argument
> will keep the reference date the same as the evaluation date, but it's
> possible to pass e.g. 2 to have a curve starting spot (on the second
> business day from the evaluation date).
>
> Luigi
>
>
> On Tue, Mar 8, 2022 at 3:29 PM Mohammad Shoja-talab <msh...@gm...>
> wrote:
>
>> 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
>> _______________________________________________
>> QuantLib-users mailing list
>> Qua...@li...
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>
|