Skip to content

Commit

Permalink
Merge 6f7bd40 into 58e92ab
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Jul 23, 2022
2 parents 58e92ab + 6f7bd40 commit 647ebc1
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 141 deletions.
44 changes: 0 additions & 44 deletions ql/instruments/zerocouponinflationswap.cpp
Expand Up @@ -117,50 +117,6 @@ namespace QuantLib {
}
}

ZeroCouponInflationSwap::ZeroCouponInflationSwap(
Type type,
Real nominal,
const Date& startDate,
const Date& maturity,
Calendar fixCalendar,
BusinessDayConvention fixConvention,
DayCounter dayCounter,
Rate fixedRate,
const ext::shared_ptr<ZeroInflationIndex>& infIndex,
const Period& observationLag,
bool adjustInfObsDates,
Calendar infCalendar,
BusinessDayConvention infConvention)
: ZeroCouponInflationSwap(type,
nominal,
startDate,
maturity,
std::move(fixCalendar),
fixConvention,
std::move(dayCounter),
fixedRate,
infIndex,
observationLag,
CPI::AsIndex,
adjustInfObsDates,
std::move(infCalendar),
infConvention) {}


void ZeroCouponInflationSwap::setupArguments(PricingEngine::arguments* args) const {
Swap::setupArguments(args);
// you don't actually need to do anything else because it is so simple
}

void ZeroCouponInflationSwap::arguments::validate() const {
Swap::arguments::validate();
// you don't actually need to do anything else because it is so simple
}

void ZeroCouponInflationSwap::fetchResults(const PricingEngine::results* r) const {
Swap::fetchResults(r);
// you don't actually need to do anything else because it is so simple
}

Real ZeroCouponInflationSwap::fairRate() const {
// What does this mean before or after trade date?
Expand Down
27 changes: 1 addition & 26 deletions ql/instruments/zerocouponinflationswap.hpp
Expand Up @@ -85,24 +85,6 @@ namespace QuantLib {
Calendar infCalendar = Calendar(),
BusinessDayConvention infConvention = BusinessDayConvention());

/*! \deprecated Use the other constructor.
Deprecated in version 1.23.
*/
QL_DEPRECATED
ZeroCouponInflationSwap(Type type,
Real nominal,
const Date& startDate, // start date of contract (only)
const Date& maturity, // this is pre-adjustment!
Calendar fixCalendar,
BusinessDayConvention fixConvention,
DayCounter dayCounter,
Rate fixedRate,
const ext::shared_ptr<ZeroInflationIndex>& infIndex,
const Period& observationLag,
bool adjustInfObsDates = false,
Calendar infCalendar = Calendar(),
BusinessDayConvention infConvention = BusinessDayConvention());

//! \name Inspectors
//@{
//! "Payer" or "Receiver" refers to the inflation leg
Expand Down Expand Up @@ -135,12 +117,6 @@ namespace QuantLib {
const Leg& inflationLeg() const;
//@}

//! \name Instrument interface
//@{
void setupArguments(PricingEngine::arguments*) const override;
void fetchResults(const PricingEngine::results* r) const override;
//@}

//! \name Results
//@{
Real fixedLegNPV() const;
Expand Down Expand Up @@ -169,13 +145,12 @@ namespace QuantLib {
class ZeroCouponInflationSwap::arguments : public Swap::arguments {
public:
Rate fixedRate;
void validate() const override;
};


class ZeroCouponInflationSwap::engine
: public GenericEngine<ZeroCouponInflationSwap::arguments,
ZeroCouponInflationSwap::results> {};
ZeroCouponInflationSwap::results> {};

}

Expand Down
23 changes: 0 additions & 23 deletions ql/termstructures/inflation/inflationhelpers.cpp
Expand Up @@ -71,30 +71,7 @@ namespace QuantLib {
}


ZeroCouponInflationSwapHelper::ZeroCouponInflationSwapHelper(
const Handle<Quote>& quote,
const Period& swapObsLag,
const Date& maturity,
Calendar calendar,
BusinessDayConvention paymentConvention,
DayCounter dayCounter,
ext::shared_ptr<ZeroInflationIndex> zii,
Handle<YieldTermStructure> nominalTermStructure)
: ZeroCouponInflationSwapHelper(quote,
swapObsLag,
maturity,
std::move(calendar),
paymentConvention,
std::move(dayCounter),
std::move(zii),
CPI::AsIndex,
std::move(nominalTermStructure)) {}


Real ZeroCouponInflationSwapHelper::impliedQuote() const {
// what does the term structure imply?
// in this case just the same value ... trivial case
// (would not be so for an inflation-linked bond)
zciis_->recalculate();
return zciis_->fairRate();
}
Expand Down
14 changes: 0 additions & 14 deletions ql/termstructures/inflation/inflationhelpers.hpp
Expand Up @@ -46,20 +46,6 @@ namespace QuantLib {
CPI::InterpolationType observationInterpolation,
Handle<YieldTermStructure> nominalTermStructure);

/*! \deprecated Use the other constructor.
Deprecated in version 1.23.
*/
QL_DEPRECATED
ZeroCouponInflationSwapHelper(
const Handle<Quote>& quote,
const Period& swapObsLag, // lag on swap observation of index
const Date& maturity,
Calendar calendar, // index may have null calendar as valid on every day
BusinessDayConvention paymentConvention,
DayCounter dayCounter,
ext::shared_ptr<ZeroInflationIndex> zii,
Handle<YieldTermStructure> nominalTermStructure);

void setTermStructure(ZeroInflationTermStructure*) override;
Real impliedQuote() const override;

Expand Down
12 changes: 2 additions & 10 deletions ql/time/daycounters/actualactual.hpp
Expand Up @@ -87,17 +87,9 @@ namespace QuantLib {
Time
yearFraction(const Date& d1, const Date& d2, const Date&, const Date&) const override;
};
static ext::shared_ptr<DayCounter::Impl> implementation(
Convention c,
const Schedule& schedule);
static ext::shared_ptr<DayCounter::Impl> implementation(Convention c,
const Schedule& schedule);
public:
/*! \deprecated Use the other constructor.
Deprecated in version 1.23.
*/
QL_DEPRECATED
ActualActual()
: DayCounter(implementation(ActualActual::ISDA, Schedule())) {}

explicit ActualActual(Convention c,
const Schedule& schedule = Schedule())
: DayCounter(implementation(c, schedule)) {}
Expand Down
8 changes: 3 additions & 5 deletions ql/time/daycounters/thirty360.cpp
Expand Up @@ -32,7 +32,7 @@ namespace QuantLib {
}

ext::shared_ptr<DayCounter::Impl>
Thirty360::implementation(Thirty360::Convention c, const Date& terminationDate, bool isLastPeriod) {
Thirty360::implementation(Thirty360::Convention c, const Date& terminationDate) {
switch (c) {
case USA:
return ext::shared_ptr<DayCounter::Impl>(new US_Impl);
Expand All @@ -46,7 +46,7 @@ namespace QuantLib {
return ext::shared_ptr<DayCounter::Impl>(new ISMA_Impl);
case ISDA:
case German:
return ext::shared_ptr<DayCounter::Impl>(new ISDA_Impl(terminationDate, isLastPeriod));
return ext::shared_ptr<DayCounter::Impl>(new ISDA_Impl(terminationDate));
case NASD:
return ext::shared_ptr<DayCounter::Impl>(new NASD_Impl);
default:
Expand Down Expand Up @@ -119,9 +119,7 @@ namespace QuantLib {

if (isLastOfFebruary(dd1, mm1, yy1)) { dd1 = 30; }

bool isTerminationDate =
terminationDate_ == Date() ? isLastPeriod_ : d2 == terminationDate_;
if (!isTerminationDate && isLastOfFebruary(dd2, mm2, yy2)) { dd2 = 30; }
if (d2 != terminationDate_ && isLastOfFebruary(dd2, mm2, yy2)) { dd2 = 30; }

return 360*(yy2-yy1) + 30*(mm2-mm1) + (dd2-dd1);
}
Expand Down
23 changes: 4 additions & 19 deletions ql/time/daycounters/thirty360.hpp
Expand Up @@ -116,38 +116,23 @@ namespace QuantLib {
};
class ISDA_Impl : public Thirty360_Impl {
public:
explicit ISDA_Impl(const Date& terminationDate, bool isLastPeriod)
: terminationDate_(terminationDate), isLastPeriod_(isLastPeriod) {}
explicit ISDA_Impl(const Date& terminationDate)
: terminationDate_(terminationDate) {}
std::string name() const override { return std::string("30E/360 (ISDA)"); }
Date::serial_type dayCount(const Date& d1, const Date& d2) const override;
private:
Date terminationDate_;
bool isLastPeriod_;
};
class NASD_Impl : public Thirty360_Impl {
public:
std::string name() const override { return std::string("30/360 (NASD)"); }
Date::serial_type dayCount(const Date& d1, const Date& d2) const override;
};
static ext::shared_ptr<DayCounter::Impl>
implementation(Convention c, const Date& terminationDate, bool isLastPeriod);
implementation(Convention c, const Date& terminationDate);
public:
/*! \deprecated Use the constructor taking a convention and possibly a termination date.
Deprecated in version 1.23.
*/
QL_DEPRECATED
Thirty360()
: DayCounter(implementation(Thirty360::BondBasis, Date(), false)) {}

/*! \deprecated Use the constructor taking a convention and possibly a termination date.
Deprecated in version 1.23.
*/
QL_DEPRECATED
Thirty360(Convention c, bool isLastPeriod)
: DayCounter(implementation(c, Date(), isLastPeriod)) {}

explicit Thirty360(Convention c, const Date& terminationDate = Date())
: DayCounter(implementation(c, terminationDate, false)) {}
: DayCounter(implementation(c, terminationDate)) {}
};

}
Expand Down

0 comments on commit 647ebc1

Please sign in to comment.