Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
averagespotpricehelper.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/averagespotpricehelper.hpp
20 \brief Price helper for average of spot price over a period.
21 \ingroup termstructures
22*/
23
24#ifndef quantext_averagespotpricehelper_hpp
25#define quantext_averagespotpricehelper_hpp
26
29#include <ql/termstructures/bootstraphelper.hpp>
30
31namespace QuantExt {
32
33typedef QuantLib::BootstrapHelper<PriceTermStructure> PriceHelper;
34
35//! Helper for bootstrapping using prices that are the average of a spot price over a period.
36//! \ingroup termstructures
38public:
39 //! \name Constructors
40 //@{
41 /*! \param price The average price quote.
42 \param index The commodity spot index.
43 \param start The start date of the averaging period. The averaging period includes the
44 start date if it is a pricing date according to the \p calendar.
45 \param end The end date of the averaging period. The averaging period includes the
46 end date if it is a pricing date according to the \p calendar.
47 \param calendar The calendar used to determine pricing dates in the averaging period. If not provided,
48 the \p index calendar is used.
49 \param useBusinessDays If set to \c false, the averaging happens on the complement of the pricing calendar
50 dates in the period.
51 */
52 AverageSpotPriceHelper(const QuantLib::Handle<QuantLib::Quote>& price,
53 const QuantLib::ext::shared_ptr<CommoditySpotIndex>& index,
54 const QuantLib::Date& start,
55 const QuantLib::Date& end,
56 const QuantLib::Calendar& calendar = QuantLib::Calendar(),
57 bool useBusinessDays = true);
58
59 /*! \param price The average price.
60 \param index The commodity spot index.
61 \param start The start date of the averaging period. The averaging period includes the
62 start date if it is a pricing date according to the \p calendar.
63 \param end The end date of the averaging period. The averaging period includes the
64 end date if it is a pricing date according to the \p calendar.
65 \param calendar The calendar used to determine pricing dates in the averaging period. If not provided,
66 the \p index calendar is used.
67 \param useBusinessDays If set to \c false, the averaging happens on the complement of the pricing calendar
68 dates in the period.
69 */
70 AverageSpotPriceHelper(QuantLib::Real price,
71 const QuantLib::ext::shared_ptr<CommoditySpotIndex>& index,
72 const QuantLib::Date& start,
73 const QuantLib::Date& end,
74 const QuantLib::Calendar& calendar = QuantLib::Calendar(),
75 bool useBusinessDays = true);
76 //@}
77
78 //! \name PriceHelper interface
79 //@{
80 QuantLib::Real impliedQuote() const override;
81 void setTermStructure(PriceTermStructure* ts) override;
82 //@}
83
84 //! \name Visitability
85 //@{
86 void accept(QuantLib::AcyclicVisitor& v) override;
87 //@}
88
89 //! \name Inspectors
90 //@{
91 QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> averageCashflow() const;
92 //@}
93
94private:
95 //! Shared initialisation method.
96 void init(const QuantLib::ext::shared_ptr<CommoditySpotIndex>& index,
97 const QuantLib::Date& start,
98 const QuantLib::Date& end,
99 const QuantLib::Calendar& calendar,
100 bool useBusinessDays);
101
102 QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> averageCashflow_;
103 QuantLib::RelinkableHandle<PriceTermStructure> termStructureHandle_;
104};
105
106}
107
108#endif
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)
void accept(QuantLib::AcyclicVisitor &v) override
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > averageCashflow_
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)
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > averageCashflow() 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.
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....
QuantLib::BootstrapHelper< PriceTermStructure > PriceHelper
Term structure of prices.