|
From: Luigi B. <lui...@gm...> - 2023-04-13 13:55:16
|
Hello Jake,
the bit of code that does the discounting should check if the discount
handle is empty. If it's not empty, it should use it; otherwise, it should
fall back to using the forecasting handle instead.
Luigi
On Thu, Apr 13, 2023 at 3:11 PM Jake Heke <jak...@gm...> wrote:
> Hi all,
> I am currently working on a pull request for class ForwardRateAgreement.
> I coded a new version of the constructor:
>
> ForwardRateAgreement(
> const Date& valueDate,
> const Date& maturityDate,
> Position::Type type,
> Rate strikeForwardRate,
> Real notionalAmount,
> Handle<YieldTermStructure> forecastCurve,
> Natural fixingDays,
> BusinessDayConvention businessDayConvention,
> Handle<YieldTermStructure> discountCurve =
> Handle<YieldTermStructure>());
>
> The last discountCurve it is used only if provided, otherwise the
> forecastCurve is used also for discounting.
> That's why I provided a default for it as discountCurve =
> Handle<YieldTermStructure>().
>
> Now, before submitting the PR I am trying to test some cases of the new
> constructor.
> Guess what? Unsurprisingly it is not working :-)
> If I try to create the FRA as:
>
> ForwardRateAgreement FRA3(valueDate,
> maturityDate,
> fraFwdType,
> strikeForwardRate,
> fraNotional,
> flatForwardTS,
> fixingDays,
> businessDayConvention);
>
> I am getting an exception in handle.hpp which is saying "empty Handle
> cannot be dereferenced". Here is the piece of code issuing the exception:
> template <class T>
> inline const ext::shared_ptr<T>& Handle<T>::operator->() const {
> QL_REQUIRE(!empty(), "empty Handle cannot be dereferenced");
> return link_->currentLink();
>
> I am getting the same exception even if I call the new constructor by
> passing explicitly the empty discount curve:
>
> ForwardRateAgreement FRA3(valueDate,
> maturityDate,
> fraFwdType,
> strikeForwardRate,
> fraNotional,
> flatForwardTS,
> fixingDays,
> businessDayConvention,
> Handle<YieldTermStructure>());
>
> What am I missing? Thanks in advance for your help.
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|