56 QL_FAIL(
"unknown futures type (" << type <<
')');
60 Time DetermineYearFraction(
const Date& earliestDate,
61 const Date& maturityDate,
62 const DayCounter& dayCounter) {
63 return dayCounter.yearFraction(earliestDate, maturityDate,
64 earliestDate, maturityDate);
70 const Date& iborStartDate,
79 CheckDate(iborStartDate, type);
83 calendar.
advance(iborStartDate, lengthInMonths *
Months, convention, endOfMonth);
91 const Date& iborStartDate,
92 const Date& iborEndDate,
97 CheckDate(iborStartDate, type);
99 const auto determineMaturityDate =
100 [&iborStartDate, &iborEndDate](
const auto nextDateCalculator) ->
Date {
102 if (iborEndDate ==
Date()) {
109 "end date (" << iborEndDate <<
") must be greater than start date ("
110 << iborStartDate <<
')');
129 QL_FAIL(
"unsupported futures type (" << type <<
')');
139 const Date& iborStartDate,
140 const ext::shared_ptr<IborIndex>& index,
144 CheckDate(iborStartDate, type);
147 const Calendar& cal = index->fixingCalendar();
149 cal.
advance(iborStartDate, index->tenor(), index->businessDayConvention());
164 return 100.0 * (1.0 - futureRate);
187 iborIndex_ = ext::make_shared<IborIndex>(
"no-fix",
195 const ext::shared_ptr<IborIndex>& i)
203 const ext::shared_ptr<IborIndex>& i)
219 bool observer =
false;
260 Date customPillarDate,
261 bool useIndexedCoupon)
262 :
FraRateHelper(rate, monthsToStart*
Months, monthsToEnd-monthsToStart, fixingDays, calendar,
263 convention, endOfMonth, dayCounter, pillarChoice, customPillarDate, useIndexedCoupon) {
265 "monthsToEnd (" << monthsToEnd <<
266 ") must be grater than monthsToStart (" << monthsToStart <<
272 const ext::shared_ptr<IborIndex>& i,
274 Date customPillarDate,
275 bool useIndexedCoupon)
276 :
FraRateHelper(rate, monthsToStart*
Months, i, pillarChoice, customPillarDate, useIndexedCoupon)
288 Date customPillarDate,
289 bool useIndexedCoupon)
291 pillarChoice_(pillarChoice), useIndexedCoupon_(useIndexedCoupon) {
294 iborIndex_ = ext::make_shared<IborIndex>(
"no-fix",
305 const ext::shared_ptr<IborIndex>& i,
307 Date customPillarDate,
308 bool useIndexedCoupon)
310 pillarChoice_(pillarChoice), useIndexedCoupon_(useIndexedCoupon) {
325 const ext::shared_ptr<IborIndex>& i,
327 Date customPillarDate,
328 bool useIndexedCoupon)
330 pillarChoice_(pillarChoice), useIndexedCoupon_(useIndexedCoupon) {
343 const ext::shared_ptr<IborIndex>& i,
345 Date customPillarDate,
346 bool useIndexedCoupon)
348 useIndexedCoupon_(useIndexedCoupon) {
374 bool observer =
false;
385 for (
Size i = 0; i <
n; ++i) {
413 QL_FAIL(
"neither periodToStart nor immOffsetStart/End given");
435 "pillar date (" <<
pillarDate_ <<
") must be later "
436 "than or equal to the instrument's earliest date (" <<
439 "pillar date (" <<
pillarDate_ <<
") must be before "
440 "or equal to the instrument's latest relevant date (" <<
462 const ext::shared_ptr<SwapIndex>& swapIndex,
467 Date customPillarDate,
469 const ext::optional<bool>& useIndexedCoupons)
470 :
SwapRateHelper(rate, swapIndex->tenor(), swapIndex->fixingCalendar(),
471 swapIndex->fixedLegTenor().frequency(), swapIndex->fixedLegConvention(),
472 swapIndex->dayCounter(), swapIndex->iborIndex(),
std::move(spread), fwdStart,
473 std::move(discount),
Null<
Natural>(), pillarChoice, customPillarDate, endOfMonth,
474 useIndexedCoupons) {}
482 const ext::shared_ptr<IborIndex>& iborIndex,
488 Date customPillarDate,
490 const ext::optional<bool>& useIndexedCoupons)
492 pillarChoice_(pillarChoice), calendar_(
std::move(calendar)),
493 fixedConvention_(fixedConvention), fixedFrequency_(fixedFrequency),
494 fixedDayCount_(
std::move(fixedDayCount)), spread_(
std::move(spread)), endOfMonth_(endOfMonth),
495 fwdStart_(fwdStart), discountHandle_(
std::move(discount)),
496 useIndexedCoupons_(useIndexedCoupons) {
501 const Date& startDate,
507 const ext::shared_ptr<IborIndex>& iborIndex,
511 Date customPillarDate,
513 const ext::optional<bool>& useIndexedCoupons)
515 pillarChoice_(pillarChoice), calendar_(
std::move(calendar)),
516 fixedConvention_(fixedConvention), fixedFrequency_(fixedFrequency),
517 fixedDayCount_(
std::move(fixedDayCount)), spread_(
std::move(spread)), endOfMonth_(endOfMonth),
518 discountHandle_(
std::move(discount)), useIndexedCoupons_(useIndexedCoupons) {
520 "fixedFrequency == Once is not supported when passing explicit "
521 "startDate and endDate");
526 Date customPillarDate) {
568 ext::shared_ptr<IborCoupon> lastCoupon =
569 ext::dynamic_pointer_cast<IborCoupon>(
swap_->floatingLeg().back());
582 "pillar date (" <<
pillarDate_ <<
") must be later "
583 "than or equal to the instrument's earliest date (" <<
586 "pillar date (" <<
pillarDate_ <<
") must be before "
587 "or equal to the instrument's latest relevant date (" <<
601 bool observer =
false;
619 static const Spread basisPoint = 1.0e-4;
620 Real floatingLegNPV =
swap_->floatingLegNPV();
623 Real totNPV = - (floatingLegNPV+spreadNPV);
624 Real result = totNPV/(
swap_->fixedLegBPS()/basisPoint);
644 ext::shared_ptr<BMAIndex> bmaIndex,
646 ext::shared_ptr<IborIndex> iborIndex)
648 calendar_(
std::move(calendar)), bmaPeriod_(bmaPeriod), bmaConvention_(bmaConvention),
649 bmaDayCount_(
std::move(bmaDayCount)), bmaIndex_(
std::move(bmaIndex)),
650 iborIndex_(
std::move(iborIndex)) {
694 swap_->setPricingEngine(ext::shared_ptr<PricingEngine>(
new
699 Date nextWednesday = (w >= 4) ?
700 d + (11 - w) *
Days :
703 clonedIndex->fixingCalendar().adjust(nextWednesday));
709 bool observer =
false;
721 return swap_->fairLiborFraction();
739 bool isFxBaseCurrencyCollateralCurrency,
743 fixingDays_(fixingDays), cal_(
std::move(calendar)), conv_(convention), eom_(endOfMonth),
744 isFxBaseCurrencyCollateralCurrency_(isFxBaseCurrencyCollateralCurrency),
745 collHandle_(
std::move(coll)), tradingCalendar_(
std::move(tradingCalendar)) {
780 Real collRatio = d1 / d2;
783 Real ratio = d1 / d2;
786 return (ratio/collRatio-1)*
spot;
788 return (collRatio/ratio-1)*
spot;
795 bool observer =
false;
ASX-related date functions.
degenerate base class for the Acyclic Visitor pattern
Bond Market Association index.
void setTermStructure(YieldTermStructure *) override
RelinkableHandle< YieldTermStructure > termStructureHandle_
ext::shared_ptr< IborIndex > iborIndex_
void accept(AcyclicVisitor &) override
void initializeDates() override
ext::shared_ptr< BMAIndex > bmaIndex_
Real impliedQuote() const override
BusinessDayConvention bmaConvention_
BMASwapRateHelper(const Handle< Quote > &liborFraction, const Period &tenor, Natural settlementDays, Calendar calendar, const Period &bmaPeriod, BusinessDayConvention bmaConvention, DayCounter bmaDayCount, ext::shared_ptr< BMAIndex > bmaIndex, ext::shared_ptr< IborIndex > index)
ext::shared_ptr< BMASwap > swap_
Base helper class for bootstrapping.
virtual void accept(AcyclicVisitor &)
virtual Date maturityDate() const
instrument's maturity date
virtual void setTermStructure(TS *)
sets the term structure to be used for pricing
bool empty() const
Returns whether or not the calendar is initialized.
Date adjust(const Date &, BusinessDayConvention convention=Following) const
Date advance(const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following, bool endOfMonth=false) const
void setTermStructure(YieldTermStructure *) override
RelinkableHandle< YieldTermStructure > termStructureHandle_
ext::shared_ptr< IborIndex > iborIndex_
void accept(AcyclicVisitor &) override
void initializeDates() override
Real impliedQuote() const override
DepositRateHelper(const std::variant< Rate, Handle< Quote > > &rate, const Period &tenor, Natural fixingDays, const Calendar &calendar, BusinessDayConvention convention, bool endOfMonth, const DayCounter &dayCounter)
Discounting engine for swaps.
Rate helper for bootstrapping over FRA rates.
ext::optional< Natural > immOffsetEnd_
void setTermStructure(YieldTermStructure *) override
ext::optional< Natural > immOffsetStart_
RelinkableHandle< YieldTermStructure > termStructureHandle_
Pillar::Choice pillarChoice_
FraRateHelper(const std::variant< Rate, Handle< Quote > > &rate, Natural monthsToStart, Natural monthsToEnd, Natural fixingDays, const Calendar &calendar, BusinessDayConvention convention, bool endOfMonth, const DayCounter &dayCounter, Pillar::Choice pillar=Pillar::LastRelevantDate, Date customPillarDate=Date(), bool useIndexedCoupon=true)
ext::shared_ptr< IborIndex > iborIndex_
ext::optional< Period > periodToStart_
void accept(AcyclicVisitor &) override
void initializeDates() override
Real impliedQuote() const override
void accept(AcyclicVisitor &) override
FuturesRateHelper(const std::variant< Real, Handle< Quote > > &price, const Date &iborStartDate, Natural lengthInMonths, const Calendar &calendar, BusinessDayConvention convention, bool endOfMonth, const DayCounter &dayCounter, const std::variant< Real, Handle< Quote > > &convexityAdjustment=0.0, Futures::Type type=Futures::IMM)
Real impliedQuote() const override
Real convexityAdjustment() const
void setTermStructure(YieldTermStructure *) override
RelinkableHandle< YieldTermStructure > termStructureHandle_
Calendar tradingCalendar_
void accept(AcyclicVisitor &) override
RelinkableHandle< YieldTermStructure > collRelinkableHandle_
Handle< YieldTermStructure > collHandle_
void initializeDates() override
BusinessDayConvention conv_
bool isFxBaseCurrencyCollateralCurrency_
Real impliedQuote() const override
FxSwapRateHelper(const Handle< Quote > &fwdPoint, Handle< Quote > spotFx, const Period &tenor, Natural fixingDays, Calendar calendar, BusinessDayConvention convention, bool endOfMonth, bool isFxBaseCurrencyCollateralCurrency, Handle< YieldTermStructure > collateralCurve, Calendar tradingCalendar=Calendar())
Shared handle to an observable.
MakeSchedule & withConvention(BusinessDayConvention)
MakeSchedule & backwards()
MakeSchedule & to(const Date &terminationDate)
MakeSchedule & withTenor(const Period &)
MakeSchedule & from(const Date &effectiveDate)
MakeSchedule & endOfMonth(bool flag=true)
MakeSchedule & withCalendar(const Calendar &)
MakeVanillaSwap & withEffectiveDate(const Date &)
MakeVanillaSwap & withFixedLegConvention(BusinessDayConvention bdc)
MakeVanillaSwap & withFixedLegTerminationDateConvention(BusinessDayConvention bdc)
MakeVanillaSwap & withFixedLegCalendar(const Calendar &cal)
MakeVanillaSwap & withTerminationDate(const Date &)
MakeVanillaSwap & withDiscountingTermStructure(const Handle< YieldTermStructure > &discountCurve)
MakeVanillaSwap & withIndexedCoupons(const ext::optional< bool > &b=true)
MakeVanillaSwap & withSettlementDays(Natural settlementDays)
MakeVanillaSwap & withFixedLegDayCount(const DayCounter &dc)
MakeVanillaSwap & withFixedLegEndOfMonth(bool flag=true)
MakeVanillaSwap & withFloatingLegCalendar(const Calendar &cal)
MakeVanillaSwap & withFloatingLegEndOfMonth(bool flag=true)
MakeVanillaSwap & withFixedLegTenor(const Period &t)
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Bootstrap helper with date schedule relative to global evaluation date.
Rate helper for bootstrapping over swap rates.
SwapRateHelper(const std::variant< Rate, Handle< Quote > > &rate, const ext::shared_ptr< SwapIndex > &swapIndex, Handle< Quote > spread={}, const Period &fwdStart=0 *Days, Handle< YieldTermStructure > discountingCurve={}, Pillar::Choice pillar=Pillar::LastRelevantDate, Date customPillarDate=Date(), bool endOfMonth=false, const ext::optional< bool > &useIndexedCoupons=ext::nullopt)
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_
void setTermStructure(YieldTermStructure *) override
BusinessDayConvention fixedConvention_
RelinkableHandle< YieldTermStructure > termStructureHandle_
ext::shared_ptr< VanillaSwap > swap_
Pillar::Choice pillarChoice_
DayCounter fixedDayCount_
Handle< YieldTermStructure > discountHandle_
ext::shared_ptr< IborIndex > iborIndex_
ext::optional< bool > useIndexedCoupons_
void accept(AcyclicVisitor &) override
Frequency fixedFrequency_
void initializeDates() override
Real impliedQuote() const override
void initialize(const ext::shared_ptr< IborIndex > &iborIndex, Date customPillarDate)
Visitor for a specific class
virtual void visit(T &)=0
Interest-rate term structure.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Frequency
Frequency of events.
BusinessDayConvention
Business Day conventions.
@ Once
only once, e.g., a zero-coupon
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
unsigned QL_INTEGER Natural
positive integer
QL_INTEGER Integer
integer number
Real Spread
spreads on interest rates
std::size_t Size
size of a container
Coupon paying a Libor-type index.
IMM-related date functions.
Helper class to instantiate standard market swaps.
Handle< Quote > handleFromVariant(const std::variant< Real, Handle< Quote > > &value)
void simplifyNotificationGraph(Instrument &instrument, const Leg &leg, bool unregisterCoupons)
Utility function to optimize the observability graph of an instrument.
empty deleter for shared_ptr
Maps optional to either the boost or std implementation.
ext::shared_ptr< BlackVolTermStructure > v
purely virtual base class for market observables
deposit, FRA, futures, and various swap rate helpers
utility functions to reduce number of notifications sent by observables
static Date nextDate(const Date &d=Date(), bool mainCycle=true)
next ASX date following the given date
static bool isASXdate(const Date &d, bool mainCycle=true)
returns whether or not the given date is an ASX date
Type
Futures type enumeration.
static bool isIMMdate(const Date &d, bool mainCycle=true)
returns whether or not the given date is an IMM date
static Date nextDate(const Date &d=Date(), bool mainCycle=true)
next IMM date following the given date
Choice
Alternatives ways of determining the pillar date.
@ CustomDate
last date relevant for instrument pricing
@ LastRelevantDate
instruments maturity date