21using QuantLib::AcyclicVisitor;
22using QuantLib::Visitor;
23using QuantLib::Calendar;
31 if (QuantLib::Visitor<CommodityCashFlow>* v1 =
dynamic_cast<QuantLib::Visitor<CommodityCashFlow>*
>(&v))
38 bool useFuturePrice,
const ext::shared_ptr<CommodityIndex>& index,
39 const ext::shared_ptr<FxIndex>& fxIndex)
40 : quantity_(quantity),
spread_(spread), gearing_(gearing), useFuturePrice_(useFuturePrice), index_(index),
48set<Date>
pricingDates(
const Date& s,
const Date& e,
const Calendar& pricingCalendar,
49 bool excludeStart,
bool includeEnd,
bool useBusinessDays) {
59 if ((useBusinessDays && pricingCalendar.isBusinessDay(start)) && excludeStart) {
60 start = pricingCalendar.advance(start, 1, Days);
63 if ((!useBusinessDays && pricingCalendar.isHoliday(start)) && excludeStart) {
64 while (pricingCalendar.isHoliday(start) && start <= end)
69 if ((useBusinessDays && pricingCalendar.isBusinessDay(end)) && !includeEnd) {
70 end = pricingCalendar.advance(end, -1, Days);
73 if ((!useBusinessDays && pricingCalendar.isHoliday(end)) && !includeEnd) {
74 while (pricingCalendar.isHoliday(end) && start <= end)
80 for (; start <= end; start++) {
88bool isPricingDate(
const Date& d,
const Calendar& pricingCalendar,
bool useBusinessDays) {
89 return ((useBusinessDays && pricingCalendar.isBusinessDay(d)) ||
90 (!useBusinessDays && pricingCalendar.isHoliday(d)));
void accept(QuantLib::AcyclicVisitor &v) override
ext::shared_ptr< FxIndex > fxIndex() const
ext::shared_ptr< CommodityIndex > index_
CommodityCashFlow(QuantLib::Real quantity, QuantLib::Real spread, QuantLib::Real gearing, bool useFuturePrice, const ext::shared_ptr< CommodityIndex > &index, const ext::shared_ptr< FxIndex > &fxIndex)
Some data and logic shared among commodity cashflows.
bool isPricingDate(const Date &d, const Calendar &pricingCalendar, bool useBusinessDays)
set< Date > pricingDates(const Date &s, const Date &e, const Calendar &pricingCalendar, bool excludeStart, bool includeEnd, bool useBusinessDays)