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

#include <qle/termstructures/averagespotpricehelper.hpp>

+ Inheritance diagram for AverageSpotPriceHelper:
+ Collaboration diagram for AverageSpotPriceHelper:

Public Member Functions

Constructors
 AverageSpotPriceHelper (const QuantLib::Handle< QuantLib::Quote > &price, const QuantLib::ext::shared_ptr< CommoditySpotIndex > &index, const QuantLib::Date &start, const QuantLib::Date &end, const QuantLib::Calendar &calendar=QuantLib::Calendar(), bool useBusinessDays=true)
 
 AverageSpotPriceHelper (QuantLib::Real price, const QuantLib::ext::shared_ptr< CommoditySpotIndex > &index, const QuantLib::Date &start, const QuantLib::Date &end, const QuantLib::Calendar &calendar=QuantLib::Calendar(), bool useBusinessDays=true)
 
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 init (const QuantLib::ext::shared_ptr< CommoditySpotIndex > &index, const QuantLib::Date &start, const QuantLib::Date &end, const QuantLib::Calendar &calendar, bool useBusinessDays)
 Shared initialisation method. More...
 

Detailed Description

Helper for bootstrapping using prices that are the average of a spot price over a period.

Definition at line 37 of file averagespotpricehelper.hpp.

Constructor & Destructor Documentation

◆ AverageSpotPriceHelper() [1/2]

AverageSpotPriceHelper ( const QuantLib::Handle< QuantLib::Quote > &  price,
const QuantLib::ext::shared_ptr< CommoditySpotIndex > &  index,
const QuantLib::Date &  start,
const QuantLib::Date &  end,
const QuantLib::Calendar &  calendar = QuantLib::Calendar(),
bool  useBusinessDays = true 
)
Parameters
priceThe average price quote.
indexThe commodity spot index.
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.
calendarThe calendar used to determine pricing dates in the averaging period. If not provided, the index calendar is used.
useBusinessDaysIf set to false, the averaging happens on the complement of the pricing calendar dates in the period.

◆ AverageSpotPriceHelper() [2/2]

AverageSpotPriceHelper ( QuantLib::Real  price,
const QuantLib::ext::shared_ptr< CommoditySpotIndex > &  index,
const QuantLib::Date &  start,
const QuantLib::Date &  end,
const QuantLib::Calendar &  calendar = QuantLib::Calendar(),
bool  useBusinessDays = true 
)
Parameters
priceThe average price.
indexThe commodity spot index.
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.
calendarThe calendar used to determine pricing dates in the averaging period. If not provided, the index calendar is used.
useBusinessDaysIf set to false, the averaging happens on the complement of the pricing calendar dates in the period.

Member Function Documentation

◆ impliedQuote()

Real impliedQuote ( ) const
override

Definition at line 77 of file averagespotpricehelper.cpp.

77 {
78 QL_REQUIRE(termStructure_, "AverageSpotPriceHelper term structure not set.");
79 return averageCashflow_->amount();
80}
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > averageCashflow_

◆ setTermStructure()

void setTermStructure ( PriceTermStructure ts)
override

Definition at line 82 of file averagespotpricehelper.cpp.

82 {
83 QuantLib::ext::shared_ptr<PriceTermStructure> temp(ts, null_deleter());
84 // Do not set the relinkable handle as an observer i.e. registerAsObserver is false here.
85 termStructureHandle_.linkTo(temp, false);
86 PriceHelper::setTermStructure(ts);
87}
QuantLib::RelinkableHandle< PriceTermStructure > termStructureHandle_

◆ accept()

void accept ( QuantLib::AcyclicVisitor &  v)
override

Definition at line 89 of file averagespotpricehelper.cpp.

89 {
90 if (auto vis = dynamic_cast<Visitor<AverageSpotPriceHelper>*>(&v))
91 vis->visit(*this);
92 else
93 PriceHelper::accept(v);
94}

◆ averageCashflow()

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

Definition at line 96 of file averagespotpricehelper.cpp.

96 {
97 return averageCashflow_;
98}

◆ init()

void init ( const QuantLib::ext::shared_ptr< CommoditySpotIndex > &  index,
const QuantLib::Date &  start,
const QuantLib::Date &  end,
const QuantLib::Calendar &  calendar,
bool  useBusinessDays 
)
private

Shared initialisation method.

Definition at line 52 of file averagespotpricehelper.cpp.

53 {
54
55 // Make a copy of the commodity spot index linked to this price helper's price term structure handle,
56 // termStructureHandle_.
57 auto indexClone = QuantLib::ext::make_shared<CommoditySpotIndex>(index->underlyingName(),
58 index->fixingCalendar(), termStructureHandle_);
59
60 // While bootstrapping is happening, this price helper's price term structure handle, termStructureHandle_, will
61 // be updated multiple times. We don't want the index notified each time.
62 indexClone->unregisterWith(termStructureHandle_);
63 registerWith(indexClone);
64
65 // Create the averaging cashflow referencing the commodity spot index. Need to specify all the defaults
66 // here just to amend the final default parameter i.e. set excludeStartDate to false.
67 averageCashflow_ = QuantLib::ext::make_shared<CommodityIndexedAverageCashFlow>(1.0, start, end, end, indexClone,
68 calendar, 0.0, 1.0, false, 0, 0, nullptr, true, false, useBusinessDays);
69
70 // Get the date index pairs involved in the averaging. The earliest date is the date of the first element
71 // and the latest date is the date of the last element.
72 const auto& mp = averageCashflow_->indices();
73 earliestDate_ = mp.begin()->first;
74 pillarDate_ = mp.rbegin()->first;
75}

Member Data Documentation

◆ averageCashflow_

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

Definition at line 102 of file averagespotpricehelper.hpp.

◆ termStructureHandle_

QuantLib::RelinkableHandle<PriceTermStructure> termStructureHandle_
private

Definition at line 103 of file averagespotpricehelper.hpp.