Skip to content

Commit

Permalink
Add forDates() to SwapRateHelper and OISRateHelper (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio authored Oct 28, 2024
2 parents 6fb803d + 959945c commit 04d0086
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions SWIG/ratehelpers.i
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ class FuturesRateHelper : public RateHelper {

%shared_ptr(SwapRateHelper)
class SwapRateHelper : public RateHelper {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") forDates;
#endif
public:
SwapRateHelper(
const Handle<Quote>& rate,
Expand Down Expand Up @@ -270,6 +273,28 @@ class SwapRateHelper : public RateHelper {
Date customPillarDate = Date(),
bool endOfMonth = false,
ext::optional<bool> withIndexedCoupons = ext::nullopt);
%extend {
static ext::shared_ptr<SwapRateHelper> forDates(
const Handle<Quote>& rate,
const Date& startDate,
const Date& endDate,
Calendar calendar,
Frequency fixedFrequency,
BusinessDayConvention fixedConvention,
DayCounter fixedDayCount,
const ext::shared_ptr<IborIndex>& index,
const Handle<Quote>& spread = Handle<Quote>(),
const Handle<YieldTermStructure>& discountingCurve = {},
Pillar::Choice pillar = Pillar::LastRelevantDate,
Date customPillarDate = Date(),
bool endOfMonth = false,
const ext::optional<bool>& withIndexedCoupons = ext::nullopt) {
return ext::make_shared<SwapRateHelper>(
rate, startDate, endDate, std::move(calendar), fixedFrequency,
fixedConvention, fixedDayCount, index, spread, discountingCurve,
pillar, customPillarDate, endOfMonth, withIndexedCoupons);
}
}
Spread spread();
ext::shared_ptr<VanillaSwap> swap();
};
Expand Down Expand Up @@ -312,6 +337,7 @@ class FixedRateBondHelper : public BondHelper {
class OISRateHelper : public RateHelper {
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
%feature("kwargs") OISRateHelper;
%feature("kwargs") forDates;
#endif
public:
OISRateHelper(
Expand All @@ -337,6 +363,37 @@ class OISRateHelper : public RateHelper {
Natural lockoutDays = 0,
bool applyObservationShift = false,
const ext::shared_ptr<FloatingRateCouponPricer>& pricer = {});
%extend {
static ext::shared_ptr<OISRateHelper> forDates(
const Date& startDate,
const Date& endDate,
const Handle<Quote>& rate,
const ext::shared_ptr<OvernightIndex>& index,
const Handle<YieldTermStructure>& discountingCurve = {},
bool telescopicValueDates = false,
Integer paymentLag = 0,
BusinessDayConvention paymentConvention = Following,
Frequency paymentFrequency = Annual,
Calendar paymentCalendar = Calendar(),
Spread overnightSpread = 0.0,
Pillar::Choice pillar = Pillar::LastRelevantDate,
Date customPillarDate = Date(),
RateAveraging::Type averagingMethod = RateAveraging::Compound,
ext::optional<bool> endOfMonth = ext::nullopt,
ext::optional<Frequency> fixedPaymentFrequency = ext::nullopt,
Calendar fixedCalendar = Calendar(),
Natural lookbackDays = Null<Natural>(),
Natural lockoutDays = 0,
bool applyObservationShift = false,
ext::shared_ptr<FloatingRateCouponPricer> pricer = {}) {
return ext::make_shared<OISRateHelper>(
startDate, endDate, rate, index, discountingCurve,
telescopicValueDates, paymentLag, paymentConvention, paymentFrequency,
paymentCalendar, overnightSpread, pillar, customPillarDate, averagingMethod,
endOfMonth, fixedPaymentFrequency, fixedCalendar, lookbackDays, lockoutDays,
applyObservationShift, pricer);
}
}
ext::shared_ptr<OvernightIndexedSwap> swap();
};

Expand Down

0 comments on commit 04d0086

Please sign in to comment.