|
From: Jake H. <jak...@gm...> - 2023-04-13 13:08:20
|
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.
|