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

#include <qle/termstructures/averagefuturepricehelper.hpp>

+ Inheritance diagram for AverageFuturePriceHelper:
+ Collaboration diagram for AverageFuturePriceHelper:

Public Member Functions

Constructors
 AverageFuturePriceHelper (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::Calendar &calendar=QuantLib::Calendar(), QuantLib::Natural deliveryDateRoll=0, QuantLib::Natural futureMonthOffset=0, bool useBusinessDays=true, QuantLib::Natural dailyExpiryOffset=QuantLib::Null< QuantLib::Natural >())
 
 AverageFuturePriceHelper (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::Calendar &calendar=QuantLib::Calendar(), QuantLib::Natural deliveryDateRoll=0, QuantLib::Natural futureMonthOffset=0, bool useBusinessDays=true, QuantLib::Natural dailyExpiryOffset=QuantLib::Null< QuantLib::Natural >())
 
PriceHelper interface
QuantLib::Real impliedQuote () const override
 
void setTermStructure (PriceTermStructure *ts) override
 
Visitability
void accept (QuantLib::AcyclicVisitor &v) override
 

Inspectors

QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlowaverageCashflow_
 
QuantLib::RelinkableHandle< PriceTermStructuretermStructureHandle_
 
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlowaverageCashflow () const
 
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::Calendar &calendar, QuantLib::Natural deliveryDateRoll, QuantLib::Natural futureMonthOffset, bool useBusinessDays, QuantLib::Natural dailyExpiryOffset)
 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 averagefuturepricehelper.hpp.

Constructor & Destructor Documentation

◆ AverageFuturePriceHelper() [1/2]

AverageFuturePriceHelper ( 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::Calendar &  calendar = QuantLib::Calendar(),
QuantLib::Natural  deliveryDateRoll = 0,
QuantLib::Natural  futureMonthOffset = 0,
bool  useBusinessDays = true,
QuantLib::Natural  dailyExpiryOffset = QuantLib::Null< QuantLib::Natural >() 
)
Parameters
priceThe average price quote.
indexThe commodity index. Used to convey the 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.
calendarThe calendar used to determine pricing dates in the averaging period. If not provided, the index calendar is used.
deliveryDateRollThe number of pricing days before the prompt future expiry date on which to roll to using the next future contract in the averaging.
futureMonthOffsetUse a positive integer to select a non-prompt future contract in the averaging.
useBusinessDaysIf set to false, the averaging happens on the complement of the pricing calendar dates in the period. This is useful for some electricity futures.
dailyExpiryOffsetIf set to Null<Natural>(), this is ignored. If set to a positive integer, it is the number of business days on the index calendar to offset each daily expiry date on each pricing date.

◆ AverageFuturePriceHelper() [2/2]

AverageFuturePriceHelper ( 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::Calendar &  calendar = QuantLib::Calendar(),
QuantLib::Natural  deliveryDateRoll = 0,
QuantLib::Natural  futureMonthOffset = 0,
bool  useBusinessDays = true,
QuantLib::Natural  dailyExpiryOffset = QuantLib::Null< QuantLib::Natural >() 
)
Parameters
priceThe average price.
indexThe commodity index. Used to convey the 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.
calendarThe calendar used to determine pricing dates in the averaging period. If not provided, the index calendar is used.
deliveryDateRollThe number of pricing days before the prompt future expiry date on which to roll to using the next future contract in the averaging.
futureMonthOffsetUse a positive integer to select a non-prompt future contract in the averaging.
useBusinessDaysIf set to false, the averaging happens on the complement of the pricing calendar dates in the period. This is useful for some electricity futures.
dailyExpiryOffsetIf set to Null<Natural>(), this is ignored. If set to a positive integer, it is the number of business days on the index calendar to offset each daily expiry date on each pricing date.

Member Function Documentation

◆ impliedQuote()

Real impliedQuote ( ) const
override

Definition at line 88 of file averagefuturepricehelper.cpp.

88 {
89 QL_REQUIRE(termStructure_, "AverageFuturePriceHelper term structure not set.");
90 averageCashflow_->update();
91 return averageCashflow_->amount();
92}
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > averageCashflow_

◆ setTermStructure()

void setTermStructure ( PriceTermStructure ts)
override

Definition at line 94 of file averagefuturepricehelper.cpp.

94 {
95 QuantLib::ext::shared_ptr<PriceTermStructure> temp(ts, null_deleter());
96 // Do not set the relinkable handle as an observer i.e. registerAsObserver is false here.
97 termStructureHandle_.linkTo(temp, false);
98 PriceHelper::setTermStructure(ts);
99}
QuantLib::RelinkableHandle< PriceTermStructure > termStructureHandle_

◆ accept()

void accept ( QuantLib::AcyclicVisitor &  v)
override

Definition at line 101 of file averagefuturepricehelper.cpp.

101 {
102 if (auto vis = dynamic_cast<Visitor<AverageFuturePriceHelper>*>(&v))
103 vis->visit(*this);
104 else
105 PriceHelper::accept(v);
106}

◆ averageCashflow()

QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > averageCashflow ( ) const

Definition at line 108 of file averagefuturepricehelper.cpp.

108 {
109 return averageCashflow_;
110}

◆ deepUpdate()

void deepUpdate ( )
override

Definition at line 112 of file averagefuturepricehelper.cpp.

112 {
114 averageCashflow_->update();
115 update();
116}

◆ 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::Calendar &  calendar,
QuantLib::Natural  deliveryDateRoll,
QuantLib::Natural  futureMonthOffset,
bool  useBusinessDays,
QuantLib::Natural  dailyExpiryOffset 
)
private

Shared initialisation method.

Definition at line 61 of file averagefuturepricehelper.cpp.

64 {
65
66 // Make a copy of the commodity index linked to this price helper's price term structure handle,
67 // termStructureHandle_.
68 auto indexClone = index->clone(Date(), termStructureHandle_);
69
70 // While bootstrapping is happening, this price helper's price term structure handle, termStructureHandle_, will
71 // be updated multiple times. We don't want the index notified each time.
72 indexClone->unregisterWith(termStructureHandle_);
73 registerWith(indexClone);
74
75 // Create the averaging cashflow referencing the commodity index.
76 averageCashflow_ = QuantLib::ext::make_shared<CommodityIndexedAverageCashFlow>(1.0, start, end, end, indexClone,
77 calendar, 0.0, 1.0, true, deliveryDateRoll, futureMonthOffset, calc, true, false, useBusinessDays,
78 CommodityQuantityFrequency::PerCalculationPeriod, Null<Natural>(), dailyExpiryOffset);
79
80 // Get the date index pairs involved in the averaging. The earliest date is the expiry date of the future contract
81 // referenced in the first element and the latest date is the expiry date of the future contract referenced in
82 // the last element.
83 const auto& mp = averageCashflow_->indices();
84 earliestDate_ = mp.begin()->second->expiryDate();
85 pillarDate_ = mp.rbegin()->second->expiryDate();
86}

Member Data Documentation

◆ averageCashflow_

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

Definition at line 133 of file averagefuturepricehelper.hpp.

◆ termStructureHandle_

QuantLib::RelinkableHandle<PriceTermStructure> termStructureHandle_
private

Definition at line 134 of file averagefuturepricehelper.hpp.