Skip to content

Commit

Permalink
Allow passing a pricer to OISRateHelper, deprecate superseded experim…
Browse files Browse the repository at this point in the history
…ental classes (#2052)
  • Loading branch information
lballabio authored Aug 7, 2024
2 parents 4e5dd72 + 94e5c22 commit 897ddbe
Show file tree
Hide file tree
Showing 12 changed files with 226 additions and 125 deletions.
1 change: 1 addition & 0 deletions cmake/GenerateHeaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function(generate_dir_headers source_dir binary_dir)
list(FILTER children_hpp EXCLUDE REGEX "fdstepconditionengine.hpp")
list(FILTER children_hpp EXCLUDE REGEX "duffsdeviceinnerproduct.hpp")
list(FILTER children_hpp EXCLUDE REGEX "dividendvanillaoption.hpp")
list(FILTER children_hpp EXCLUDE REGEX "averageoiscouponpricer.hpp")

file(GLOB children_dir RELATIVE ${source_dir} "${source_dir}/*")
list(FILTER children_dir EXCLUDE REGEX "CMakeFiles")
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/averageois/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ all.hpp: Makefile.am
echo "/* This file is automatically generated; do not edit. */" > ${srcdir}/$@
echo "/* Add the files to be included into Makefile.am instead. */" >> ${srcdir}/$@
echo >> ${srcdir}/$@
for i in $(filter-out all.hpp, $(this_include_HEADERS)); do \
for i in $(filter-out all.hpp averageoiscouponpricer.hpp, $(this_include_HEADERS)); do \
echo "#include <${subdir}/$$i>" >> ${srcdir}/$@; \
done
echo >> ${srcdir}/$@
Expand Down
1 change: 0 additions & 1 deletion ql/experimental/averageois/all.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* This file is automatically generated; do not edit. */
/* Add the files to be included into Makefile.am instead. */

#include <ql/experimental/averageois/averageoiscouponpricer.hpp>
#include <ql/experimental/averageois/arithmeticaverageois.hpp>
#include <ql/experimental/averageois/arithmeticoisratehelper.hpp>
#include <ql/experimental/averageois/makearithmeticaverageois.hpp>
Expand Down
4 changes: 4 additions & 0 deletions ql/experimental/averageois/arithmeticaverageois.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

namespace QuantLib {

QL_DEPRECATED_DISABLE_WARNING

ArithmeticAverageOIS::ArithmeticAverageOIS(Type type,
Real nominal,
Schedule fixedLegSchedule,
Expand Down Expand Up @@ -143,4 +145,6 @@ namespace QuantLib {
return legNPV_[1];
}

QL_DEPRECATED_ENABLE_WARNING

}
19 changes: 8 additions & 11 deletions ql/experimental/averageois/arithmeticaverageois.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ namespace QuantLib {
class Schedule;
class OvernightIndex;

//! Arithemtic Average OIS: fix vs arithmetic average of overnight rate
class ArithmeticAverageOIS : public Swap {
/*! \deprecated Use OvernightIndexedSwap instead.
Deprecated in version 1.36.
*/
class [[deprecated("Use OvernightIndexedSwap instead")]] ArithmeticAverageOIS : public Swap {
public:
ArithmeticAverageOIS(Type type,
Real nominal,
Expand All @@ -60,7 +62,10 @@ namespace QuantLib {
//! \name Inspectors
//@{
Type type() const { return type_; }
Real nominal() const;
Real nominal() const {
QL_REQUIRE(nominals_.size()==1, "varying nominals");
return nominals_[0];
}
std::vector<Real> nominals() const { return nominals_; }

//const Schedule& schedule() { return schedule_; }
Expand Down Expand Up @@ -107,14 +112,6 @@ namespace QuantLib {
Real vol_;
};


// inline

inline Real ArithmeticAverageOIS::nominal() const {
QL_REQUIRE(nominals_.size()==1, "varying nominals");
return nominals_[0];
}

}

#endif
4 changes: 4 additions & 0 deletions ql/experimental/averageois/arithmeticoisratehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

namespace QuantLib {

QL_DEPRECATED_DISABLE_WARNING

ArithmeticOISRateHelper::ArithmeticOISRateHelper(Natural settlementDays,
const Period& tenor, // swap maturity
Frequency fixedLegPaymentFrequency,
Expand Down Expand Up @@ -106,4 +108,6 @@ namespace QuantLib {
RateHelper::accept(v);
}

QL_DEPRECATED_ENABLE_WARNING

}
8 changes: 6 additions & 2 deletions ql/experimental/averageois/arithmeticoisratehelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@

namespace QuantLib {

//! Rate helper for bootstrapping over Overnight Indexed Swap rates
class ArithmeticOISRateHelper : public RelativeDateRateHelper {
/*! \deprecated Use OISRateHelper instead.
Deprecated in version 1.36.
*/
class [[deprecated("Use OISRateHelper instead")]] ArithmeticOISRateHelper : public RelativeDateRateHelper {
public:
QL_DEPRECATED_DISABLE_WARNING
ArithmeticOISRateHelper(
Natural settlementDays,
const Period& tenor, // swap maturity
Expand Down Expand Up @@ -80,6 +83,7 @@ namespace QuantLib {
Real vol_;
bool byApprox_;

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
4 changes: 4 additions & 0 deletions ql/experimental/averageois/makearithmeticaverageois.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace QuantLib {

QL_DEPRECATED_DISABLE_WARNING

MakeArithmeticAverageOIS::MakeArithmeticAverageOIS(
const Period& swapTenor,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
Expand Down Expand Up @@ -234,4 +236,6 @@ namespace QuantLib {
return *this;
}

QL_DEPRECATED_ENABLE_WARNING

}
11 changes: 7 additions & 4 deletions ql/experimental/averageois/makearithmeticaverageois.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@

namespace QuantLib {

//! helper class
/*! This class provides a more comfortable way
to instantiate arithemtic average overnight indexed swaps.
/*! \deprecated Use MakeOIS instead.
Deprecated in version 1.36.
*/
class MakeArithmeticAverageOIS {
class [[deprecated("Use MakeOIS instead")]] MakeArithmeticAverageOIS {
public:
QL_DEPRECATED_DISABLE_WARNING

MakeArithmeticAverageOIS(const Period& swapTenor,
const ext::shared_ptr<OvernightIndex>& overnightIndex,
Rate fixedRate = Null<Rate>(),
Expand Down Expand Up @@ -95,6 +96,8 @@ namespace QuantLib {
DayCounter fixedDayCount_;

ext::shared_ptr<PricingEngine> engine_;

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
18 changes: 14 additions & 4 deletions ql/termstructures/yield/oisratehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <ql/instruments/makeois.hpp>
#include <ql/instruments/simplifynotificationgraph.hpp>
#include <ql/cashflows/couponpricer.hpp>
#include <ql/pricingengines/swap/discountingswapengine.hpp>
#include <ql/termstructures/yield/oisratehelper.hpp>
#include <ql/utilities/null_deleter.hpp>
Expand Down Expand Up @@ -47,15 +48,17 @@ namespace QuantLib {
Calendar fixedCalendar,
Natural lookbackDays,
Natural lockoutDays,
bool applyObservationShift)
bool applyObservationShift,
ext::shared_ptr<FloatingRateCouponPricer> pricer)
: RelativeDateRateHelper(fixedRate), pillarChoice_(pillar), settlementDays_(settlementDays), tenor_(tenor),
discountHandle_(std::move(discount)), telescopicValueDates_(telescopicValueDates),
paymentLag_(paymentLag), paymentConvention_(paymentConvention),
paymentFrequency_(paymentFrequency), paymentCalendar_(std::move(paymentCalendar)),
forwardStart_(forwardStart), overnightSpread_(overnightSpread),
averagingMethod_(averagingMethod), endOfMonth_(endOfMonth),
fixedPaymentFrequency_(fixedPaymentFrequency), fixedCalendar_(std::move(fixedCalendar)),
lookbackDays_(lookbackDays), lockoutDays_(lockoutDays), applyObservationShift_(applyObservationShift) {
lookbackDays_(lookbackDays), lockoutDays_(lockoutDays), applyObservationShift_(applyObservationShift),
pricer_(std::move(pricer)) {

overnightIndex_ =
ext::dynamic_pointer_cast<OvernightIndex>(overnightIndex->clone(termStructureHandle_));
Expand Down Expand Up @@ -99,6 +102,9 @@ namespace QuantLib {
}
swap_ = tmp;

if (pricer_)
setCouponPricer(swap_->overnightLeg(), pricer_);

simplifyNotificationGraph(*swap_, true);

earliestDate_ = swap_->startDate();
Expand Down Expand Up @@ -181,7 +187,8 @@ namespace QuantLib {
const Calendar& fixedCalendar,
Natural lookbackDays,
Natural lockoutDays,
bool applyObservationShift)
bool applyObservationShift,
ext::shared_ptr<FloatingRateCouponPricer> pricer)
: RateHelper(fixedRate), discountHandle_(std::move(discount)),
telescopicValueDates_(telescopicValueDates), averagingMethod_(averagingMethod) {

Expand Down Expand Up @@ -222,6 +229,9 @@ namespace QuantLib {
}
swap_ = tmp;

if (pricer)
setCouponPricer(swap_->overnightLeg(), pricer);

earliestDate_ = swap_->startDate();
Date lastPaymentDate = std::max(swap_->overnightLeg().back()->date(),
swap_->fixedLeg().back()->date());
Expand All @@ -247,7 +257,7 @@ namespace QuantLib {
: DatedOISRateHelper(startDate, endDate, fixedRate, overnightIndex, std::move(discount), telescopicValueDates,
averagingMethod, paymentLag, paymentConvention, paymentFrequency, paymentCalendar,
overnightSpread, endOfMonth, fixedPaymentFrequency, fixedCalendar) {}

void DatedOISRateHelper::setTermStructure(YieldTermStructure* t) {
// do not set the relinkable handle as an observer -
// force recalculation when needed
Expand Down
11 changes: 8 additions & 3 deletions ql/termstructures/yield/oisratehelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

namespace QuantLib {

class FloatingRateCouponPricer;

//! Rate helper for bootstrapping over Overnight Indexed Swap rates
class OISRateHelper : public RelativeDateRateHelper {
public:
Expand All @@ -55,7 +57,8 @@ namespace QuantLib {
Calendar fixedCalendar = Calendar(),
Natural lookbackDays = Null<Natural>(),
Natural lockoutDays = 0,
bool applyObservationShift = false);
bool applyObservationShift = false,
ext::shared_ptr<FloatingRateCouponPricer> pricer = {});
//! \name RateHelper interface
//@{
Real impliedQuote() const override;
Expand Down Expand Up @@ -98,6 +101,7 @@ namespace QuantLib {
Natural lookbackDays_;
Natural lockoutDays_;
bool applyObservationShift_;
ext::shared_ptr<FloatingRateCouponPricer> pricer_;
};

//! Rate helper for bootstrapping over Overnight Indexed Swap rates
Expand All @@ -121,8 +125,9 @@ namespace QuantLib {
const Calendar& fixedCalendar = Calendar(),
Natural lookbackDays = Null<Natural>(),
Natural lockoutDays = 0,
bool applyObservationShift = false);

bool applyObservationShift = false,
ext::shared_ptr<FloatingRateCouponPricer> pricer = {});

/*! \deprecated Use the overload without forward start.
Deprecated in version 1.35.
*/
Expand Down
Loading

0 comments on commit 897ddbe

Please sign in to comment.