Skip to content

Commit

Permalink
Merge e0a6d10 into daba5ab
Browse files Browse the repository at this point in the history
  • Loading branch information
yyuuhhjjnnmm committed Feb 1, 2024
2 parents daba5ab + e0a6d10 commit 680c644
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 35 deletions.
30 changes: 12 additions & 18 deletions ql/termstructures/yield/bondhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,12 @@ namespace QuantLib {
bool exCouponEndOfMonth,
const Bond::Price::Type priceType)
: BondHelper(price,
ext::shared_ptr<Bond>(
new FixedRateBond(settlementDays, faceAmount, schedule,
coupons, dayCounter, paymentConvention,
redemption, issueDate, paymentCalendar,
exCouponPeriod, exCouponCalendar,
exCouponConvention, exCouponEndOfMonth)),
priceType) {
fixedRateBond_ = ext::dynamic_pointer_cast<FixedRateBond>(bond_);
}
ext::make_shared<FixedRateBond>(settlementDays, faceAmount, schedule,
coupons, dayCounter, paymentConvention,
redemption, issueDate, paymentCalendar,
exCouponPeriod, exCouponCalendar,
exCouponConvention, exCouponEndOfMonth),
priceType) {}

void FixedRateBondHelper::accept(AcyclicVisitor& v) {
auto* v1 = dynamic_cast<Visitor<FixedRateBondHelper>*>(&v);
Expand Down Expand Up @@ -133,15 +130,12 @@ namespace QuantLib {
bool exCouponEndOfMonth,
const Bond::Price::Type priceType)
: BondHelper(price,
ext::shared_ptr<Bond>(
new CPIBond(settlementDays, faceAmount, growthOnly, baseCPI,
observationLag, cpiIndex, observationInterpolation,
schedule, fixedRate, accrualDayCounter, paymentConvention,
issueDate, paymentCalendar, exCouponPeriod, exCouponCalendar,
exCouponConvention, exCouponEndOfMonth)),
priceType) {
cpiBond_ = ext::dynamic_pointer_cast<CPIBond>(bond_);
}
ext::make_shared<CPIBond>(settlementDays, faceAmount, growthOnly, baseCPI,
observationLag, cpiIndex, observationInterpolation,
schedule, fixedRate, accrualDayCounter, paymentConvention,
issueDate, paymentCalendar, exCouponPeriod, exCouponCalendar,
exCouponConvention, exCouponEndOfMonth),
priceType) {}

void CPIBondHelper::accept(AcyclicVisitor& v) {
auto* v1 = dynamic_cast<Visitor<CPIBondHelper>*>(&v);
Expand Down
57 changes: 40 additions & 17 deletions ql/termstructures/yield/bondhelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ namespace QuantLib {
//! Fixed-coupon bond helper for curve bootstrap
class FixedRateBondHelper : public BondHelper {
public:
// needed to avoid warning about deprecated data member;
// it can be removed once the latter is gone.
QL_DEPRECATED_DISABLE_WARNING
~FixedRateBondHelper() override = default;
QL_DEPRECATED_ENABLE_WARNING

FixedRateBondHelper(const Handle<Quote>& price,
Natural settlementDays,
Real faceAmount,
Expand All @@ -90,22 +96,38 @@ namespace QuantLib {
bool exCouponEndOfMonth = false,
Bond::Price::Type priceType = Bond::Price::Clean);

//! \name Additional inspectors
//@{
ext::shared_ptr<FixedRateBond> fixedRateBond() const;
//@}
/*! \deprecated Do not use; this method is broken and will be removed.
Deprecated in version 1.34.
*/
[[deprecated("Do not use; this method is broken and will be removed.")]]
ext::shared_ptr<FixedRateBond> fixedRateBond() const {
QL_DEPRECATED_DISABLE_WARNING
return fixedRateBond_;
QL_DEPRECATED_ENABLE_WARNING
}

//! \name Visitability
//@{
void accept(AcyclicVisitor&) override;
//@}
protected:
/*! \deprecated Do not use; this pointer is always null.
Deprecated in version 1.34.
*/
[[deprecated("Do not use; this pointer is always null.")]]
ext::shared_ptr<FixedRateBond> fixedRateBond_;
};


//! CPI bond helper for curve bootstrap
class CPIBondHelper : public BondHelper {
public:
// needed to avoid warning about deprecated data member;
// it can be removed once the latter is gone.
QL_DEPRECATED_DISABLE_WARNING
~CPIBondHelper() override = default;
QL_DEPRECATED_ENABLE_WARNING

CPIBondHelper(const Handle<Quote>& price,
Natural settlementDays,
Real faceAmount,
Expand All @@ -126,15 +148,25 @@ namespace QuantLib {
bool exCouponEndOfMonth = false,
Bond::Price::Type priceType = Bond::Price::Clean);

//! \name Additional inspectors
//@{
ext::shared_ptr<CPIBond> cpiBond() const;
//@}
/*! \deprecated Do not use; this method is broken and will be removed.
Deprecated in version 1.34.
*/
[[deprecated("Do not use; this method is broken and will be removed.")]]
ext::shared_ptr<CPIBond> cpiBond() const {
QL_DEPRECATED_DISABLE_WARNING
return cpiBond_;
QL_DEPRECATED_ENABLE_WARNING
}

//! \name Visitability
//@{
void accept(AcyclicVisitor&) override;
//@}
protected:
/*! \deprecated Do not use; this pointer is always null.
Deprecated in version 1.34.
*/
[[deprecated("Do not use; this pointer is always null.")]]
ext::shared_ptr<CPIBond> cpiBond_;
};

Expand All @@ -149,15 +181,6 @@ namespace QuantLib {
return priceType_;
}

inline ext::shared_ptr<FixedRateBond>
FixedRateBondHelper::fixedRateBond() const {
return fixedRateBond_;
}

inline ext::shared_ptr<CPIBond>
CPIBondHelper::cpiBond() const {
return cpiBond_;
}

}

Expand Down

0 comments on commit 680c644

Please sign in to comment.