23#ifndef quantext_commodity_indexed_cash_flow_hpp
24#define quantext_commodity_indexed_cash_flow_hpp
26#include <boost/optional.hpp>
27#include <ql/cashflow.hpp>
28#include <ql/patterns/visitor.hpp>
29#include <ql/time/schedule.hpp>
44 const QuantLib::Date& paymentDate,
const ext::shared_ptr<CommodityIndex>&
index,
46 const Date& contractDate = Date(),
47 const ext::shared_ptr<FutureExpiryCalculator>& calc =
nullptr,
49 const ext::shared_ptr<FxIndex>&
fxIndex =
nullptr);
55 const ext::shared_ptr<CommodityIndex>&
index, QuantLib::Natural paymentLag,
56 const QuantLib::Calendar& paymentCalendar,
57 QuantLib::BusinessDayConvention paymentConvention, QuantLib::Natural pricingLag,
58 const QuantLib::Calendar& pricingLagCalendar, QuantLib::Real
spread = 0.0,
62 const ext::shared_ptr<FutureExpiryCalculator>& calc =
nullptr,
63 const QuantLib::Date& paymentDateOverride = Date(),
64 const QuantLib::Date& pricingDateOverride = Date(),
66 const ext::shared_ptr<FxIndex>&
fxIndex =
nullptr,
67 const bool spotAveragingFrontCoupon =
false,
68 const QuantLib::Calendar& pricingCalendar = QuantLib::Calendar(),
69 bool includeEndDate =
true,
70 bool excludeStartDate =
true);
84 const std::vector<std::pair<QuantLib::Date, ext::shared_ptr<CommodityIndex>>>&
indices()
const override {
return indices_; }
96 QuantLib::Real
fixing()
const override;
106 QuantLib::Real
amount()
const override;
111 void accept(QuantLib::AcyclicVisitor& v)
override;
126 std::vector<std::pair<QuantLib::Date, ext::shared_ptr<CommodityIndex>>>
indices_;
134 void init(
const ext::shared_ptr<FutureExpiryCalculator>& calc,
135 const QuantLib::Date& contractDate = QuantLib::Date(),
137 const QuantLib::Date& startDate = QuantLib::Date(),
const QuantLib::Date& endDate = QuantLib::Date(),
138 const QuantLib::Natural paymentLag = 0,
139 const QuantLib::BusinessDayConvention paymentConvention = QuantLib::Unadjusted,
140 const QuantLib::Calendar& paymentCalendar = QuantLib::NullCalendar(),
141 const QuantLib::Calendar& pricingCalendar = QuantLib::Calendar(),
bool includeEndDate =
true,
142 bool excludeStartDate =
true);
149 CommodityIndexedLeg(
const QuantLib::Schedule& schedule,
const ext::shared_ptr<CommodityIndex>& index);
177 operator Leg()
const;
195 ext::shared_ptr<FutureExpiryCalculator>
calc_;
QuantLib::Real spread() const
bool useFuturePrice() const
ext::shared_ptr< FxIndex > fxIndex() const
QuantLib::Real gearing() const
ext::shared_ptr< CommodityIndex > index() const
QuantLib::Real quantity() const
Cash flow dependent on a single commodity spot price or futures settlement price on a given pricing d...
std::vector< std::pair< QuantLib::Date, ext::shared_ptr< CommodityIndex > > > indices_
void performCalculations() const override
void init(const ext::shared_ptr< FutureExpiryCalculator > &calc, const QuantLib::Date &contractDate=QuantLib::Date(), const PaymentTiming paymentTiming=PaymentTiming::InArrears, const QuantLib::Date &startDate=QuantLib::Date(), const QuantLib::Date &endDate=QuantLib::Date(), const QuantLib::Natural paymentLag=0, const QuantLib::BusinessDayConvention paymentConvention=QuantLib::Unadjusted, const QuantLib::Calendar &paymentCalendar=QuantLib::NullCalendar(), const QuantLib::Calendar &pricingCalendar=QuantLib::Calendar(), bool includeEndDate=true, bool excludeStartDate=true)
Shared initialisation.
QuantLib::Real fixing() const override
QuantLib::Real periodQuantity_
bool useFutureExpiryDate() const
CommodityIndexedCashFlow(QuantLib::Real quantity, const QuantLib::Date &pricingDate, const QuantLib::Date &paymentDate, const ext::shared_ptr< CommodityIndex > &index, QuantLib::Real spread=0.0, QuantLib::Real gearing=1.0, bool useFuturePrice=false, const Date &contractDate=Date(), const ext::shared_ptr< FutureExpiryCalculator > &calc=nullptr, QuantLib::Natural dailyExpiryOffset=QuantLib::Null< QuantLib::Natural >(), const ext::shared_ptr< FxIndex > &fxIndex=nullptr)
Constructor taking an explicit pricingDate and paymentDate.
QuantLib::Real periodQuantity() const override
QuantLib::Natural dailyExpiryOffset() const
QuantLib::Date lastPricingDate() const override
void accept(QuantLib::AcyclicVisitor &v) override
const QuantLib::Date & pricingDate() const
QuantLib::Real amount() const override
QuantLib::Natural futureMonthOffset_
bool useFutureExpiryDate_
const std::set< QuantLib::Date > & spotAveragingPricingDates() const
std::set< QuantLib::Date > spotAveragingPricingDates_
QuantLib::Natural dailyExpiryOffset_
bool isAveragingFrontMonthCashflow(const QuantLib::Date &asof) const
QuantLib::Date paymentDate_
ext::shared_ptr< CommodityIndex > spotIndex_
QuantLib::Natural futureMonthOffset() const
const std::vector< std::pair< QuantLib::Date, ext::shared_ptr< CommodityIndex > > > & indices() const override
Return a map of pricing date and corresponding commodity index.
void setPeriodQuantity(QuantLib::Real periodQuantity)
Allow the full calculation period quantity to be updated.
CommodityIndexedCashFlow(QuantLib::Real quantity, const QuantLib::Date &startDate, const QuantLib::Date &endDate, const ext::shared_ptr< CommodityIndex > &index, QuantLib::Natural paymentLag, const QuantLib::Calendar &paymentCalendar, QuantLib::BusinessDayConvention paymentConvention, QuantLib::Natural pricingLag, const QuantLib::Calendar &pricingLagCalendar, QuantLib::Real spread=0.0, QuantLib::Real gearing=1.0, PaymentTiming paymentTiming=PaymentTiming::InArrears, bool isInArrears=true, bool useFuturePrice=false, bool useFutureExpiryDate=true, QuantLib::Natural futureMonthOffset=0, const ext::shared_ptr< FutureExpiryCalculator > &calc=nullptr, const QuantLib::Date &paymentDateOverride=Date(), const QuantLib::Date &pricingDateOverride=Date(), QuantLib::Natural dailyExpiryOffset=QuantLib::Null< QuantLib::Natural >(), const ext::shared_ptr< FxIndex > &fxIndex=nullptr, const bool spotAveragingFrontCoupon=false, const QuantLib::Calendar &pricingCalendar=QuantLib::Calendar(), bool includeEndDate=true, bool excludeStartDate=true)
const ext::shared_ptr< CommodityIndex > & spotIndex() const
QuantLib::Date pricingDate_
QuantLib::Date date() const override
Helper class building a sequence of commodity indexed cashflows.
QuantLib::Calendar pricingLagCalendar_
CommodityIndexedLeg & excludeStartDate(bool flag=true)
CommodityIndexedLeg & withPricingLagCalendar(const QuantLib::Calendar &pricingLagCalendar)
QuantLib::Calendar pricingCalendar_
CommodityIndexedLeg & paymentTiming(CommodityIndexedCashFlow::PaymentTiming paymentTiming)
QuantLib::BusinessDayConvention paymentConvention_
CommodityIndexedLeg & payAtMaturity(bool flag=false)
CommodityIndexedLeg & withIsAveraging(const bool isAveraging)
CommodityIndexedCashFlow::PaymentTiming paymentTiming_
CommodityIndexedLeg & includeEndDate(bool flag=true)
ext::shared_ptr< FutureExpiryCalculator > calc_
std::vector< QuantLib::Date > paymentDates_
CommodityIndexedLeg & withFutureMonthOffset(QuantLib::Natural futureMonthOffset)
CommodityIndexedLeg & withQuantities(QuantLib::Real quantity)
CommodityIndexedLeg & withPaymentDates(const std::vector< QuantLib::Date > &paymentDates)
QuantLib::Natural futureMonthOffset_
bool useFutureExpiryDate_
CommodityIndexedLeg & withQuantities(const std::vector< QuantLib::Real > &quantities)
ext::shared_ptr< FxIndex > fxIndex_
CommodityIndexedLeg & withFxIndex(const ext::shared_ptr< FxIndex > &fxIndex)
QuantLib::Natural dailyExpiryOffset_
CommodityIndexedLeg & withFutureExpiryCalculator(const ext::shared_ptr< FutureExpiryCalculator > &calc=nullptr)
CommodityIndexedLeg & withPaymentLag(QuantLib::Natural paymentLag)
QuantLib::Natural paymentLag_
CommodityIndexedLeg & inArrears(bool flag=true)
CommodityIndexedLeg & withGearings(QuantLib::Real gearing)
CommodityIndexedLeg & withDailyExpiryOffset(QuantLib::Natural dailyExpiryOffset)
std::vector< QuantLib::Date > pricingDates_
CommodityIndexedLeg & withPaymentCalendar(const QuantLib::Calendar &paymentCalendar)
CommodityIndexedLeg & withPricingDates(const std::vector< QuantLib::Date > &pricingDates)
ext::shared_ptr< CommodityIndex > index_
std::vector< QuantLib::Real > quantities_
QuantLib::Calendar paymentCalendar_
CommodityIndexedLeg & withSpreads(QuantLib::Real spread)
CommodityIndexedLeg & useFuturePrice(bool flag=false)
CommodityIndexedLeg & withPricingCalendar(const QuantLib::Calendar &pricingCalendar)
std::vector< QuantLib::Real > spreads_
CommodityIndexedLeg & withPaymentConvention(QuantLib::BusinessDayConvention paymentConvention)
CommodityIndexedLeg & withSpreads(const std::vector< QuantLib::Real > &spreads)
std::vector< QuantLib::Real > gearings_
CommodityIndexedLeg & withPricingLag(QuantLib::Natural pricingLag)
QuantLib::Natural pricingLag_
CommodityIndexedLeg & useFutureExpiryDate(bool flag=true)
CommodityIndexedLeg & withGearings(const std::vector< QuantLib::Real > &gearings)
Some data and logic shared among commodity cashflows.
commodity index class for holding commodity spot and futures price histories and forwarding.
Base class for classes that perform date calculations for future contracts.
set< Date > pricingDates(const Date &s, const Date &e, const Calendar &pricingCalendar, bool excludeStart, bool includeEnd, bool useBusinessDays)