Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commoditybasisfutureindex.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/indexes/commoditybasisfutureindex.hpp
20 \brief commodity basis future index class for holding price histories and forwarding.
21 \ingroup indexes
22*/
23
24#pragma once
25
26#include <ql/cashflow.hpp>
29
30namespace QuantExt {
31
32//! Commodity Basis Future Index
33/*! This index can represent futures prices derived from basis future index and a base future index
34 \ingroup indexes
35*/
37public:
38 CommodityBasisFutureIndex(const std::string& underlyingName, const QuantLib::Date& expiryDate,
39 const QuantLib::Calendar& fixingCalendar,
40 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& basisFec,
41 const QuantLib::ext::shared_ptr<QuantExt::CommodityIndex>& baseIndex,
42 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& baseFec,
43 const QuantLib::Handle<QuantExt::PriceTermStructure>& priceCurve =
44 QuantLib::Handle<QuantExt::PriceTermStructure>(),
45 const bool addBasis = true, const QuantLib::Size monthOffset = 0,
46 const bool baseIsAveraging = false, const bool priceAsHistoricalFixing = true);
47
48 CommodityBasisFutureIndex(const std::string& underlyingName, const QuantLib::Date& expiryDate,
49 const QuantLib::Calendar& fixingCalendar,
50 const QuantLib::ext::shared_ptr<CommodityBasisPriceTermStructure>& priceCurve);
51
52 //! Implement the base clone. Ajust the base future to match the same contract month
53 QuantLib::ext::shared_ptr<CommodityIndex>
54 clone(const QuantLib::Date& expiryDate = QuantLib::Date(),
55 const boost::optional<QuantLib::Handle<PriceTermStructure>>& ts = boost::none) const override;
56
57 QuantLib::Real pastFixing(const QuantLib::Date& fixingDate) const override;
58
59 const QuantLib::ext::shared_ptr<QuantExt::CommodityIndex>& baseIndex() { return baseIndex_; }
60 QuantLib::ext::shared_ptr<QuantLib::CashFlow> baseCashflow(const QuantLib::Date& paymentDate = QuantLib::Date()) const;
61
62private:
63 QuantLib::ext::shared_ptr<FutureExpiryCalculator> basisFec_;
64 QuantLib::ext::shared_ptr<QuantExt::CommodityIndex> baseIndex_;
65 QuantLib::ext::shared_ptr<FutureExpiryCalculator> baseFec_;
67 QuantLib::Size monthOffset_;
70 QuantLib::ext::shared_ptr<QuantLib::CashFlow> cashflow_;
71};
72
73} // namespace QuantExt
QuantLib::ext::shared_ptr< FutureExpiryCalculator > baseFec_
const QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > & baseIndex()
QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > baseIndex_
QuantLib::ext::shared_ptr< FutureExpiryCalculator > basisFec_
QuantLib::ext::shared_ptr< CommodityIndex > clone(const QuantLib::Date &expiryDate=QuantLib::Date(), const boost::optional< QuantLib::Handle< PriceTermStructure > > &ts=boost::none) const override
Implement the base clone. Ajust the base future to match the same contract month.
QuantLib::ext::shared_ptr< QuantLib::CashFlow > cashflow_
QuantLib::Real pastFixing(const QuantLib::Date &fixingDate) const override
QuantLib::ext::shared_ptr< QuantLib::CashFlow > baseCashflow(const QuantLib::Date &paymentDate=QuantLib::Date()) const
const QuantLib::Date & expiryDate() const
Calendar fixingCalendar() const override
const Handle< QuantExt::PriceTermStructure > & priceCurve() const
std::string underlyingName() const
A commodity price curve created from a base price curve and a collection of basis quotes.
commodity index class for holding commodity spot and futures price histories and forwarding.