Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commoditybasispricecurvewrapper.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/commoditybasispricecurvewrapper.hpp
20 \brief A commodity price curve created from a generic price curve and a basis curve
21 \ingroup termstructures
22*/
23
24#pragma once
25
26#include <ql/patterns/lazyobject.hpp>
28
29namespace QuantExt {
30
32public:
33 CommodityBasisPriceCurveWrapper(const QuantLib::Date& referenceDate,
34 const QuantLib::ext::shared_ptr<PriceTermStructure>& priceCurve,
35 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& basisFec,
36 const QuantLib::ext::shared_ptr<CommodityIndex>& baseIndex,
37 const QuantLib::ext::shared_ptr<FutureExpiryCalculator>& baseFec, bool addBasis = true,
38 QuantLib::Size monthOffset = 0, bool averagingBaseCashflow = false,
39 bool priceAsHistFixing = true)
40 : CommodityBasisPriceTermStructure(referenceDate, basisFec, baseIndex, baseFec, addBasis, monthOffset,
41 averagingBaseCashflow, priceAsHistFixing),
42 priceCurve_(priceCurve) {
43 registerWith(priceCurve_);
44 }
45
46 CommodityBasisPriceCurveWrapper(const QuantLib::ext::shared_ptr<CommodityBasisPriceTermStructure>& referenceCurve,
47 const QuantLib::ext::shared_ptr<CommodityIndex>& baseIndex,
48 const QuantLib::ext::shared_ptr<PriceTermStructure>& priceCurve)
50 referenceCurve->referenceDate(), referenceCurve->calendar(), referenceCurve->dayCounter(),
51 referenceCurve->basisFutureExpiryCalculator(), baseIndex, referenceCurve->baseFutureExpiryCalculator(),
52 referenceCurve->addBasis(), referenceCurve->monthOffset(), referenceCurve->averagingBaseCashflow(),
53 referenceCurve->priceAsHistoricalFixing()),
54 priceCurve_(priceCurve) {
55 registerWith(priceCurve_);
56 };
57
58 QuantLib::Date maxDate() const override { return priceCurve_->maxDate(); }
59
60 void update() override {
61 LazyObject::update();
62 TermStructure::update();
63 }
64
65 QuantLib::Natural settlementDays() const override { return priceCurve_->settlementDays(); }
66
67 QuantLib::Time minTime() const override { return priceCurve_->minTime(); }
68 const QuantLib::Currency& currency() const override { return priceCurve_->currency(); }
69 std::vector<QuantLib::Date> pillarDates() const override { return priceCurve_->pillarDates(); }
70
71private:
72 void performCalculations() const override {}
73 QuantLib::Real priceImpl(QuantLib::Time t) const override { return priceCurve_->price(t, allowsExtrapolation()); }
74
75 QuantLib::ext::shared_ptr<QuantExt::PriceTermStructure> priceCurve_;
76};
77} // namespace QuantExt
QuantLib::Time minTime() const override
The minimum time for which the curve can return values.
CommodityBasisPriceCurveWrapper(const QuantLib::Date &referenceDate, const QuantLib::ext::shared_ptr< PriceTermStructure > &priceCurve, 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 priceAsHistFixing=true)
const QuantLib::Currency & currency() const override
The currency in which prices are expressed.
CommodityBasisPriceCurveWrapper(const QuantLib::ext::shared_ptr< CommodityBasisPriceTermStructure > &referenceCurve, const QuantLib::ext::shared_ptr< CommodityIndex > &baseIndex, const QuantLib::ext::shared_ptr< PriceTermStructure > &priceCurve)
QuantLib::ext::shared_ptr< QuantExt::PriceTermStructure > priceCurve_
std::vector< QuantLib::Date > pillarDates() const override
The pillar dates for the PriceTermStructure.
QuantLib::Real priceImpl(QuantLib::Time t) const override
Price calculation.
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.
An interface for a commodity price curve created from a base price curve and a collection of basis qu...