Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
averagefuturepricehelper.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file qle/termstructures/averagefuturepricehelper.hpp
20 \brief Price helper for average of future settlement prices over a period.
21 \ingroup termstructures
22*/
23
24#ifndef quantext_averagefuturepricehelper_hpp
25#define quantext_averagefuturepricehelper_hpp
26
30#include <ql/termstructures/bootstraphelper.hpp>
31
32namespace QuantExt {
33
34typedef QuantLib::BootstrapHelper<PriceTermStructure> PriceHelper;
35
36//! Helper for bootstrapping using prices that are the average of future settlement prices over a period.
37//! \ingroup termstructures
39public:
40 //! \name Constructors
41 //@{
42 /*! \param price The average price quote.
43 \param index The commodity index. Used to convey the commodity's name and calendar. The underlying
44 averaging cashflow may reference more than one commodity future indices.
45 \param start The start date of the averaging period. The averaging period includes the
46 start date if it is a pricing date according to the \p calendar.
47 \param end The end date of the averaging period. The averaging period includes the
48 end date if it is a pricing date according to the \p calendar.
49 \param calc A FutureExpiryCalculator instance.
50 \param calendar The calendar used to determine pricing dates in the averaging period. If not
51 provided, the \p index calendar is used.
52 \param deliveryDateRoll The number of pricing days before the prompt future expiry date on which to roll to
53 using the next future contract in the averaging.
54 \param futureMonthOffset Use a positive integer to select a non-prompt future contract in the averaging.
55 \param useBusinessDays If set to \c false, the averaging happens on the complement of the pricing calendar
56 dates in the period. This is useful for some electricity futures.
57 \param dailyExpiryOffset If set to \c Null<Natural>(), this is ignored. If set to a positive integer, it is
58 the number of business days on the \c index calendar to offset each daily expiry date
59 on each pricing date.
60 */
61 AverageFuturePriceHelper(const QuantLib::Handle<QuantLib::Quote>& price,
62 const QuantLib::ext::shared_ptr<CommodityIndex>& index,
63 const QuantLib::Date& start,
64 const QuantLib::Date& end,
65 const ext::shared_ptr<FutureExpiryCalculator>& calc,
66 const QuantLib::Calendar& calendar = QuantLib::Calendar(),
67 QuantLib::Natural deliveryDateRoll = 0,
68 QuantLib::Natural futureMonthOffset = 0,
69 bool useBusinessDays = true,
70 QuantLib::Natural dailyExpiryOffset = QuantLib::Null<QuantLib::Natural>());
71
72 /*! \param price The average price.
73 \param index The commodity index. Used to convey the commodity's name and calendar. The underlying
74 averaging cashflow may reference more than one commodity future indices.
75 \param start The start date of the averaging period. The averaging period includes the
76 start date if it is a pricing date according to the \p calendar.
77 \param end The end date of the averaging period. The averaging period includes the
78 end date if it is a pricing date according to the \p calendar.
79 \param calc A FutureExpiryCalculator instance.
80 \param calendar The calendar used to determine pricing dates in the averaging period. If not
81 provided, the \p index calendar is used.
82 \param deliveryDateRoll The number of pricing days before the prompt future expiry date on which to roll to
83 using the next future contract in the averaging.
84 \param futureMonthOffset Use a positive integer to select a non-prompt future contract in the averaging.
85 \param useBusinessDays If set to \c false, the averaging happens on the complement of the pricing calendar
86 dates in the period. This is useful for some electricity futures.
87 \param dailyExpiryOffset If set to \c Null<Natural>(), this is ignored. If set to a positive integer, it is
88 the number of business days on the \c index calendar to offset each daily expiry date
89 on each pricing date.
90 */
91 AverageFuturePriceHelper(QuantLib::Real price,
92 const QuantLib::ext::shared_ptr<CommodityIndex>& index,
93 const QuantLib::Date& start,
94 const QuantLib::Date& end,
95 const ext::shared_ptr<FutureExpiryCalculator>& calc,
96 const QuantLib::Calendar& calendar = QuantLib::Calendar(),
97 QuantLib::Natural deliveryDateRoll = 0,
98 QuantLib::Natural futureMonthOffset = 0,
99 bool useBusinessDays = true,
100 QuantLib::Natural dailyExpiryOffset = QuantLib::Null<QuantLib::Natural>());
101 //@}
102
103 //! \name PriceHelper interface
104 //@{
105 QuantLib::Real impliedQuote() const override;
106 void setTermStructure(PriceTermStructure* ts) override;
107 //@}
108
109 //! \name Visitability
110 //@{
111 void accept(QuantLib::AcyclicVisitor& v) override;
112 //@}
113
114 //! \name Inspectors
115 //@{
116 QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> averageCashflow() const;
117 //@}
118
119 void deepUpdate() override;
120
121private:
122 //! Shared initialisation method.
123 void init(const QuantLib::ext::shared_ptr<CommodityIndex>& index,
124 const QuantLib::Date& start,
125 const QuantLib::Date& end,
126 const ext::shared_ptr<FutureExpiryCalculator>& calc,
127 const QuantLib::Calendar& calendar,
128 QuantLib::Natural deliveryDateRoll,
129 QuantLib::Natural futureMonthOffset,
130 bool useBusinessDays,
131 QuantLib::Natural dailyExpiryOffset);
132
133 QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> averageCashflow_;
134 QuantLib::RelinkableHandle<PriceTermStructure> termStructureHandle_;
135};
136
137}
138
139#endif
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 >())
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.
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 >())
void accept(QuantLib::AcyclicVisitor &v) override
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > averageCashflow_
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > averageCashflow() const
QuantLib::Real impliedQuote() const override
QuantLib::RelinkableHandle< PriceTermStructure > termStructureHandle_
void setTermStructure(PriceTermStructure *ts) override
Cash flow dependent on the average commodity spot price or future's settlement price over a period....
Base class for classes that perform date calculations for future contracts.
QuantLib::BootstrapHelper< PriceTermStructure > PriceHelper
Term structure of prices.