Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commoditybasispricetermstructure.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 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/commoditybasispricetermstructure.hpp
20 \brief An interface for a commodity price curve created from a base price curve and a collection of basis quotes
21 \ingroup termstructures
22*/
23
24#pragma once
25
26#include <map>
30#include <ql/time/calendars/nullcalendar.hpp>
31
32namespace QuantExt {
33
35public:
36 CommodityBasisPriceTermStructure(const QuantLib::Date& referenceDate, const QuantLib::Calendar& cal,
37 const QuantLib::DayCounter& dc,
38 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& basisFec,
39 const QuantLib::ext::shared_ptr<CommodityIndex>& baseIndex,
40 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& baseFec, bool addBasis = true,
41 QuantLib::Size monthOffset = 0, bool averagingBaseCashflow = false,
42 bool priceAsHistoricalFixing = true)
43 : PriceTermStructure(referenceDate, cal, dc), basisFec_(basisFec),
46 registerWith(baseIndex_);
47 }
48
49 CommodityBasisPriceTermStructure(const QuantLib::Date& referenceDate,
50 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& basisFec,
51 const QuantLib::ext::shared_ptr<CommodityIndex>& baseIndex,
52 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& baseFec, bool addBasis = true,
53 QuantLib::Size monthOffset = 0, bool averagingBaseCashflow = false,
54 bool priceAsHistoricalFixing = true)
55 : PriceTermStructure(referenceDate, QuantLib::NullCalendar(), baseIndex->priceCurve()->dayCounter()), basisFec_(basisFec),
58 registerWith(baseIndex_);
59 }
60
61
62 //! Inspectors
63 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& basisFutureExpiryCalculator() const { return basisFec_; }
64 const QuantLib::ext::shared_ptr<CommodityIndex>& baseIndex() const { return baseIndex_; }
65 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& baseFutureExpiryCalculator() const { return baseFec_; }
66 bool addBasis() const { return addBasis_; }
69 QuantLib::Size monthOffset() const { return monthOffset_; }
70
71protected:
72 QuantLib::ext::shared_ptr<FutureExpiryCalculator> basisFec_;
73 QuantLib::ext::shared_ptr<CommodityIndex> baseIndex_;
74 QuantLib::ext::shared_ptr<FutureExpiryCalculator> baseFec_;
76 QuantLib::Size monthOffset_;
79};
80} // namespace QuantExt
QuantLib::ext::shared_ptr< FutureExpiryCalculator > baseFec_
const QuantLib::ext::shared_ptr< CommodityIndex > & baseIndex() const
const QuantLib::ext::shared_ptr< FutureExpiryCalculator > & baseFutureExpiryCalculator() const
const QuantLib::ext::shared_ptr< FutureExpiryCalculator > & basisFutureExpiryCalculator() const
Inspectors.
CommodityBasisPriceTermStructure(const QuantLib::Date &referenceDate, const QuantLib::ext::shared_ptr< FutureExpiryCalculator > &basisFec, const QuantLib::ext::shared_ptr< CommodityIndex > &baseIndex, const QuantLib::ext::shared_ptr< FutureExpiryCalculator > &baseFec, bool addBasis=true, QuantLib::Size monthOffset=0, bool averagingBaseCashflow=false, bool priceAsHistoricalFixing=true)
QuantLib::ext::shared_ptr< FutureExpiryCalculator > basisFec_
QuantLib::ext::shared_ptr< CommodityIndex > baseIndex_
CommodityBasisPriceTermStructure(const QuantLib::Date &referenceDate, const QuantLib::Calendar &cal, const QuantLib::DayCounter &dc, const QuantLib::ext::shared_ptr< FutureExpiryCalculator > &basisFec, const QuantLib::ext::shared_ptr< CommodityIndex > &baseIndex, const QuantLib::ext::shared_ptr< FutureExpiryCalculator > &baseFec, bool addBasis=true, QuantLib::Size monthOffset=0, bool averagingBaseCashflow=false, bool priceAsHistoricalFixing=true)
Base class for classes that perform date calculations for future contracts.
Term structure of prices.