Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
AverageOffPeakPowerHelper Class Reference

#include <qle/termstructures/averageoffpeakpowerhelper.hpp>

+ Inheritance diagram for AverageOffPeakPowerHelper:
+ Collaboration diagram for AverageOffPeakPowerHelper:

Public Member Functions

Constructors
 AverageOffPeakPowerHelper (const QuantLib::Handle< QuantLib::Quote > &price, const QuantLib::ext::shared_ptr< CommodityIndex > &index, const QuantLib::Date &start, const QuantLib::Date &end, const ext::shared_ptr< FutureExpiryCalculator > &calc, const QuantLib::ext::shared_ptr< CommodityIndex > &peakIndex, const QuantLib::Calendar &peakCalendar, QuantLib::Natural peakHoursPerDay=16)
 
 AverageOffPeakPowerHelper (QuantLib::Real price, const QuantLib::ext::shared_ptr< CommodityIndex > &index, const QuantLib::Date &start, const QuantLib::Date &end, const ext::shared_ptr< FutureExpiryCalculator > &calc, const QuantLib::ext::shared_ptr< CommodityIndex > &peakIndex, const QuantLib::Calendar &peakCalendar, QuantLib::Natural peakHoursPerDay=16)
 
PriceHelper interface
QuantLib::Real impliedQuote () const override
 
void setTermStructure (PriceTermStructure *ts) override
 

Visitability

QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlowbusinessOffPeak_
 
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlowholidayOffPeak_
 
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlowholidayPeak_
 
QuantLib::Natural peakDays_
 
QuantLib::Natural nonPeakDays_
 
QuantLib::RelinkableHandle< PriceTermStructuretermStructureHandle_
 
void accept (QuantLib::AcyclicVisitor &v) override
 
void deepUpdate () override
 
void init (const QuantLib::ext::shared_ptr< CommodityIndex > &index, const QuantLib::Date &start, const QuantLib::Date &end, const ext::shared_ptr< FutureExpiryCalculator > &calc, const QuantLib::ext::shared_ptr< CommodityIndex > &peakIndex, const QuantLib::Calendar &peakCalendar, QuantLib::Natural peakHoursPerDay)
 Shared initialisation method. More...
 

Detailed Description

Helper for bootstrapping using prices that are the average of future settlement prices over a period.

Definition at line 38 of file averageoffpeakpowerhelper.hpp.

Constructor & Destructor Documentation

◆ AverageOffPeakPowerHelper() [1/2]

AverageOffPeakPowerHelper ( const QuantLib::Handle< QuantLib::Quote > &  price,
const QuantLib::ext::shared_ptr< CommodityIndex > &  index,
const QuantLib::Date &  start,
const QuantLib::Date &  end,
const ext::shared_ptr< FutureExpiryCalculator > &  calc,
const QuantLib::ext::shared_ptr< CommodityIndex > &  peakIndex,
const QuantLib::Calendar &  peakCalendar,
QuantLib::Natural  peakHoursPerDay = 16 
)
Parameters
priceThe average price quote.
indexThe commodity index. Used to convey the off-peak commodity's name and calendar. The underlying averaging cashflow may reference more than one commodity future indices.
startThe start date of the averaging period. The averaging period includes the start date if it is a pricing date according to the calendar.
endThe end date of the averaging period. The averaging period includes the end date if it is a pricing date according to the calendar.
calcA FutureExpiryCalculator instance.
peakIndexThe commodity index for the peak electricity prices.
peakCalendarThe calendar used to determine peak dates in the averaging period.
peakHoursPerDayThe number of peak hours per day.

◆ AverageOffPeakPowerHelper() [2/2]

AverageOffPeakPowerHelper ( QuantLib::Real  price,
const QuantLib::ext::shared_ptr< CommodityIndex > &  index,
const QuantLib::Date &  start,
const QuantLib::Date &  end,
const ext::shared_ptr< FutureExpiryCalculator > &  calc,
const QuantLib::ext::shared_ptr< CommodityIndex > &  peakIndex,
const QuantLib::Calendar &  peakCalendar,
QuantLib::Natural  peakHoursPerDay = 16 
)
Parameters
priceThe average price.
indexThe commodity index. Used to convey the off-peak commodity's name and calendar. The underlying averaging cashflow may reference more than one commodity future indices.
startThe start date of the averaging period. The averaging period includes the start date if it is a pricing date according to the calendar.
endThe end date of the averaging period. The averaging period includes the end date if it is a pricing date according to the calendar.
calcA FutureExpiryCalculator instance.
peakIndexThe commodity index for the peak electricity prices.
peakCalendarThe calendar used to determine peak dates in the averaging period.
peakHoursPerDayThe number of peak hours per day.

Member Function Documentation

◆ impliedQuote()

Real impliedQuote ( ) const
override

Definition at line 101 of file averageoffpeakpowerhelper.cpp.

101 {
102 QL_REQUIRE(termStructure_, "AverageFuturePriceHelper term structure not set.");
103 businessOffPeak_->update();
104 holidayOffPeak_->update();
105 holidayPeak_->update();
106 return (peakDays_ * businessOffPeak_->amount() + nonPeakDays_ * (holidayOffPeak_->amount()
107 + holidayPeak_->amount())) / (peakDays_ + nonPeakDays_);
108}
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > holidayOffPeak_
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > businessOffPeak_
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > holidayPeak_

◆ setTermStructure()

void setTermStructure ( PriceTermStructure ts)
override

Definition at line 110 of file averageoffpeakpowerhelper.cpp.

110 {
111 QuantLib::ext::shared_ptr<PriceTermStructure> temp(ts, null_deleter());
112 // Do not set the relinkable handle as an observer i.e. registerAsObserver is false here.
113 termStructureHandle_.linkTo(temp, false);
114 PriceHelper::setTermStructure(ts);
115}
QuantLib::RelinkableHandle< PriceTermStructure > termStructureHandle_

◆ accept()

void accept ( QuantLib::AcyclicVisitor &  v)
override

Definition at line 117 of file averageoffpeakpowerhelper.cpp.

117 {
118 if (auto vis = dynamic_cast<Visitor<AverageOffPeakPowerHelper>*>(&v))
119 vis->visit(*this);
120 else
121 PriceHelper::accept(v);
122}

◆ deepUpdate()

void deepUpdate ( )
override

Definition at line 124 of file averageoffpeakpowerhelper.cpp.

124 {
126 businessOffPeak_->update();
127 if (holidayOffPeak_)
128 holidayOffPeak_->update();
129 if (holidayPeak_)
130 holidayPeak_->update();
131}

◆ init()

void init ( const QuantLib::ext::shared_ptr< CommodityIndex > &  index,
const QuantLib::Date &  start,
const QuantLib::Date &  end,
const ext::shared_ptr< FutureExpiryCalculator > &  calc,
const QuantLib::ext::shared_ptr< CommodityIndex > &  peakIndex,
const QuantLib::Calendar &  peakCalendar,
QuantLib::Natural  peakHoursPerDay 
)
private

Shared initialisation method.

Definition at line 59 of file averageoffpeakpowerhelper.cpp.

62 {
63
64 QL_REQUIRE(peakHoursPerDay <= 24, "AverageOffPeakPowerHelper: peak hours per day should not be greater than 24.");
65 Natural ophpd = 24 - peakHoursPerDay;
66
67 // Make a copy of the commodity index linked to this price helper's price term structure handle,
68 // termStructureHandle_.
69 auto indexClone = index->clone(Date(), termStructureHandle_);
70
71 // While bootstrapping is happening, this price helper's price term structure handle, termStructureHandle_, will
72 // be updated multiple times. We don't want the index notified each time.
73 indexClone->unregisterWith(termStructureHandle_);
74 registerWith(indexClone);
75
76 // Create the business day off-peak portion of the cashflow.
77 bool useBusinessDays = true;
78 businessOffPeak_ = QuantLib::ext::make_shared<CommodityIndexedAverageCashFlow>(1.0, start, end, end, indexClone,
79 peakCalendar, 0.0, 1.0, true, 0, 0, calc, true, false, useBusinessDays);
80 peakDays_ = businessOffPeak_->indices().size();
81
82 // Create the holiday off-peak portion of the cashflow.
83 useBusinessDays = false;
84 holidayOffPeak_ = QuantLib::ext::make_shared<CommodityIndexedAverageCashFlow>(ophpd / 24.0, start, end, end, indexClone,
85 peakCalendar, 0.0, 1.0, true, 0, 0, calc, true, false, useBusinessDays);
86 nonPeakDays_ = holidayOffPeak_->indices().size();
87
88 // Create the holiday peak portion of the cashflow.
89 holidayPeak_ = QuantLib::ext::make_shared<CommodityIndexedAverageCashFlow>(peakHoursPerDay / 24.0, start, end, end,
90 peakIndex, peakCalendar, 0.0, 1.0, true, 0, 0, calc, true, false, useBusinessDays);
91
92 // Get the date index pairs involved in the averaging. The earliest date is the expiry date of the future contract
93 // referenced in the first element and the latest date is the expiry date of the future contract referenced in
94 // the last element. We must look at both off peak cashflows here.
95 const auto& mpBop = businessOffPeak_->indices();
96 const auto& mpHop = holidayOffPeak_->indices();
97 earliestDate_ = min(mpBop.begin()->second->expiryDate(), mpHop.begin()->second->expiryDate());
98 pillarDate_ = max(mpBop.rbegin()->second->expiryDate(), mpHop.rbegin()->second->expiryDate());
99}
CompiledFormula min(CompiledFormula x, const CompiledFormula &y)
CompiledFormula max(CompiledFormula x, const CompiledFormula &y)
+ Here is the call graph for this function:

Member Data Documentation

◆ businessOffPeak_

QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> businessOffPeak_
private

Definition at line 108 of file averageoffpeakpowerhelper.hpp.

◆ holidayOffPeak_

QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> holidayOffPeak_
private

Definition at line 109 of file averageoffpeakpowerhelper.hpp.

◆ holidayPeak_

QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> holidayPeak_
private

Definition at line 110 of file averageoffpeakpowerhelper.hpp.

◆ peakDays_

QuantLib::Natural peakDays_
private

Definition at line 111 of file averageoffpeakpowerhelper.hpp.

◆ nonPeakDays_

QuantLib::Natural nonPeakDays_
private

Definition at line 112 of file averageoffpeakpowerhelper.hpp.

◆ termStructureHandle_

QuantLib::RelinkableHandle<PriceTermStructure> termStructureHandle_
private

Definition at line 114 of file averageoffpeakpowerhelper.hpp.