25#ifndef quantext_commodity_indexed_average_cash_flow_hpp
26#define quantext_commodity_indexed_average_cash_flow_hpp
28#include <ql/cashflow.hpp>
29#include <ql/patterns/visitor.hpp>
30#include <ql/time/schedule.hpp>
54 const QuantLib::Date& paymentDate,
const ext::shared_ptr<CommodityIndex>&
index,
55 const QuantLib::Calendar& pricingCalendar = QuantLib::Calendar(), QuantLib::Real
spread = 0.0,
57 QuantLib::Natural
futureMonthOffset = 0,
const ext::shared_ptr<FutureExpiryCalculator>& calc =
nullptr,
58 bool includeEndDate =
true,
bool excludeStartDate =
true,
bool useBusinessDays =
true,
60 QuantLib::Natural
hoursPerDay = QuantLib::Null<QuantLib::Natural>(),
62 const boost::optional<std::pair<QuantLib::Calendar, QuantLib::Real>>&
offPeakPowerData = boost::none,
63 const ext::shared_ptr<FxIndex>&
fxIndex =
nullptr);
68 QuantLib::Natural paymentLag, QuantLib::Calendar paymentCalendar,
69 QuantLib::BusinessDayConvention paymentConvention,
const ext::shared_ptr<CommodityIndex>&
index,
70 const QuantLib::Calendar& pricingCalendar = QuantLib::Calendar(), QuantLib::Real
spread = 0.0,
73 const ext::shared_ptr<FutureExpiryCalculator>& calc =
nullptr,
bool includeEndDate =
true,
74 bool excludeStartDate =
true,
const QuantLib::Date& paymentDateOverride = Date(),
bool useBusinessDays =
true,
76 QuantLib::Natural
hoursPerDay = QuantLib::Null<QuantLib::Natural>(),
78 const boost::optional<std::pair<QuantLib::Calendar, QuantLib::Real>>&
offPeakPowerData = boost::none,
79 const ext::shared_ptr<FxIndex>&
fxIndex =
nullptr);
86 ext::shared_ptr<CommodityIndex>
index()
const {
return index_; }
94 const boost::optional<std::pair<QuantLib::Calendar, QuantLib::Real>>&
offPeakPowerData()
const {
105 const std::vector<std::pair<QuantLib::Date, ext::shared_ptr<CommodityIndex>>>&
indices()
const override {
return indices_; }
120 QuantLib::Real
amount()
const override;
125 void accept(QuantLib::AcyclicVisitor& v)
override;
139 QuantLib::Real
fixing()
const override;
153 std::vector<std::pair<QuantLib::Date, ext::shared_ptr<CommodityIndex>>>
indices_;
167 void init(
const ext::shared_ptr<FutureExpiryCalculator>& calc);
204 withOffPeakPowerData(
const boost::optional<std::pair<QuantLib::Calendar, QuantLib::Real>>& offPeakPowerData);
207 operator Leg()
const;
223 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_
QuantLib::Real quantity() const
std::vector< std::pair< QuantLib::Date, ext::shared_ptr< CommodityIndex > > > indices_
const QuantLib::Date & endDate() const
QuantLib::Calendar pricingCalendar_
void performCalculations() const override
QuantLib::Real fixing() const override
QuantLib::Real periodQuantity_
CommodityIndexedAverageCashFlow(QuantLib::Real quantity, const QuantLib::Date &startDate, const QuantLib::Date &endDate, const QuantLib::Date &paymentDate, const ext::shared_ptr< CommodityIndex > &index, const QuantLib::Calendar &pricingCalendar=QuantLib::Calendar(), QuantLib::Real spread=0.0, QuantLib::Real gearing=1.0, bool useFuturePrice=false, QuantLib::Natural deliveryDateRoll=0, QuantLib::Natural futureMonthOffset=0, const ext::shared_ptr< FutureExpiryCalculator > &calc=nullptr, bool includeEndDate=true, bool excludeStartDate=true, bool useBusinessDays=true, CommodityQuantityFrequency quantityFrequency=CommodityQuantityFrequency::PerCalculationPeriod, QuantLib::Natural hoursPerDay=QuantLib::Null< QuantLib::Natural >(), QuantLib::Natural dailyExpiryOffset=QuantLib::Null< QuantLib::Natural >(), bool unrealisedQuantity=false, const boost::optional< std::pair< QuantLib::Calendar, QuantLib::Real > > &offPeakPowerData=boost::none, const ext::shared_ptr< FxIndex > &fxIndex=nullptr)
Constructor taking an explicit paymentDate.
QuantLib::Real periodQuantity() const override
QuantLib::Natural dailyExpiryOffset() const
const QuantLib::Date & startDate() const
QuantLib::Date lastPricingDate() const override
void accept(QuantLib::AcyclicVisitor &v) override
bool useBusinessDays() const
QuantLib::Natural hoursPerDay() const
void updateQuantity()
Set the period quantity based on the quantity and quantity frequency parameter.
const boost::optional< std::pair< QuantLib::Calendar, QuantLib::Real > > & offPeakPowerData() const
CommodityIndexedAverageCashFlow(QuantLib::Real quantity, const QuantLib::Date &startDate, const QuantLib::Date &endDate, QuantLib::Natural paymentLag, QuantLib::Calendar paymentCalendar, QuantLib::BusinessDayConvention paymentConvention, const ext::shared_ptr< CommodityIndex > &index, const QuantLib::Calendar &pricingCalendar=QuantLib::Calendar(), QuantLib::Real spread=0.0, QuantLib::Real gearing=1.0, PaymentTiming paymentTiming=PaymentTiming::InArrears, bool useFuturePrice=false, QuantLib::Natural deliveryDateRoll=0, QuantLib::Natural futureMonthOffset=0, const ext::shared_ptr< FutureExpiryCalculator > &calc=nullptr, bool includeEndDate=true, bool excludeStartDate=true, const QuantLib::Date &paymentDateOverride=Date(), bool useBusinessDays=true, CommodityQuantityFrequency quantityFrequency=CommodityQuantityFrequency::PerCalculationPeriod, QuantLib::Natural hoursPerDay=QuantLib::Null< QuantLib::Natural >(), QuantLib::Natural dailyExpiryOffset=QuantLib::Null< QuantLib::Natural >(), bool unrealisedQuantity=false, const boost::optional< std::pair< QuantLib::Calendar, QuantLib::Real > > &offPeakPowerData=boost::none, const ext::shared_ptr< FxIndex > &fxIndex=nullptr)
Constructor that deduces payment date from endDate using payment conventions.
QuantLib::Real amount() const override
QuantLib::Natural futureMonthOffset_
QuantLib::Natural hoursPerDay_
CommodityQuantityFrequency quantityFrequency_
QuantLib::Natural deliveryDateRoll() const
boost::optional< std::pair< QuantLib::Calendar, QuantLib::Real > > offPeakPowerData_
QuantLib::Natural dailyExpiryOffset_
CommodityQuantityFrequency quantityFrequency() const
QuantLib::Date paymentDate_
void init(const ext::shared_ptr< FutureExpiryCalculator > &calc)
Shared initialisation.
std::map< QuantLib::Date, QuantLib::Real > weights_
QuantLib::Natural futureMonthOffset() const
const std::vector< std::pair< QuantLib::Date, ext::shared_ptr< CommodityIndex > > > & indices() const override
QuantLib::Natural deliveryDateRoll_
bool unrealisedQuantity() const
ext::shared_ptr< CommodityIndex > index() const
QuantLib::Date startDate_
QuantLib::Date date() const override
QuantLib::Real averagePrice_
Helper class building a sequence of commodity indexed average cashflows.
CommodityIndexedAverageLeg & useFuturePrice(bool flag=false)
QuantLib::Calendar pricingCalendar_
CommodityIndexedAverageLeg & withPaymentLag(QuantLib::Natural paymentLag)
QuantLib::BusinessDayConvention paymentConvention_
CommodityIndexedAverageLeg & includeEndDate(bool flag=true)
CommodityIndexedAverageLeg & excludeStartDate(bool flag=true)
CommodityIndexedAverageLeg & withFutureMonthOffset(QuantLib::Natural futureMonthOffset)
CommodityIndexedAverageLeg & withGearings(QuantLib::Real gearing)
CommodityIndexedAverageLeg & withSpreads(const std::vector< QuantLib::Real > &spreads)
CommodityIndexedAverageLeg & paymentTiming(CommodityIndexedAverageCashFlow::PaymentTiming paymentTiming)
CommodityIndexedAverageLeg & withDeliveryDateRoll(QuantLib::Natural deliveryDateRoll)
ext::shared_ptr< FutureExpiryCalculator > calc_
CommodityIndexedAverageLeg & withQuantityFrequency(CommodityQuantityFrequency quantityFrequency)
std::vector< QuantLib::Date > paymentDates_
QuantLib::Natural futureMonthOffset_
QuantLib::Natural hoursPerDay_
CommodityIndexedAverageLeg & withPaymentConvention(QuantLib::BusinessDayConvention paymentConvention)
ext::shared_ptr< FxIndex > fxIndex_
CommodityQuantityFrequency quantityFrequency_
CommodityIndexedAverageLeg & withPaymentDates(const std::vector< QuantLib::Date > &paymentDates)
boost::optional< std::pair< QuantLib::Calendar, QuantLib::Real > > offPeakPowerData_
QuantLib::Natural dailyExpiryOffset_
CommodityIndexedAverageLeg & withDailyExpiryOffset(QuantLib::Natural dailyExpiryOffset)
CommodityIndexedAverageLeg & withQuantities(const std::vector< QuantLib::Real > &quantities)
CommodityIndexedAverageLeg & withQuantities(QuantLib::Real quantity)
QuantLib::Natural paymentLag_
CommodityIndexedAverageLeg & withPaymentCalendar(const QuantLib::Calendar &paymentCalendar)
ext::shared_ptr< CommodityIndex > index_
std::vector< QuantLib::Real > quantities_
CommodityIndexedAverageLeg & withHoursPerDay(QuantLib::Natural hoursPerDay)
CommodityIndexedAverageLeg & useBusinessDays(bool flag=true)
QuantLib::Calendar paymentCalendar_
CommodityIndexedAverageLeg & withFutureExpiryCalculator(const ext::shared_ptr< FutureExpiryCalculator > &calc=nullptr)
CommodityIndexedAverageLeg & withPricingCalendar(const QuantLib::Calendar &pricingCalendar)
CommodityIndexedAverageLeg & withGearings(const std::vector< QuantLib::Real > &gearings)
QuantLib::Natural deliveryDateRoll_
std::vector< QuantLib::Real > spreads_
std::vector< QuantLib::Real > gearings_
CommodityIndexedAverageLeg & withSpreads(QuantLib::Real spread)
CommodityIndexedAverageLeg & unrealisedQuantity(bool flag=false)
CommodityIndexedAverageCashFlow::PaymentTiming paymentTiming_
CommodityIndexedAverageLeg & withOffPeakPowerData(const boost::optional< std::pair< QuantLib::Calendar, QuantLib::Real > > &offPeakPowerData)
CommodityIndexedAverageLeg & withFxIndex(const ext::shared_ptr< FxIndex > &fxIndex)
CommodityIndexedAverageLeg & payAtMaturity(bool flag=false)
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.
CommodityQuantityFrequency
Enumeration indicating the frequency associated with a commodity quantity.