Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityspreadoptionengine.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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/pricingengines/commodityspreadoptionengine.hpp
20 \brief commodity spread option engine
21 \ingroup engines
22*/
23
24#pragma once
25
29
30#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
31#include <ql/termstructures/yieldtermstructure.hpp>
33
34namespace QuantExt {
35
36/*! Commodity Spread Option Engine
37 Uses the Kirk Approximation described in Iain J. Clark - Commodity Option Pricing - Section 2.9
38 Rho is the correlation between two commodities and for asian future spreads the
39 intra-asset correlation between two future contracts are parametrized as \f$\rho(s, t) = \exp(-\beta * \abs(s -
40 t))\f$ where \f$s\f$ and \f$t\f$ are times to futures expiry.
41 */
43public:
44 CommoditySpreadOptionAnalyticalEngine(const QuantLib::Handle<QuantLib::YieldTermStructure>& discountCurve,
45 const QuantLib::Handle<QuantLib::BlackVolTermStructure>& volTSLongAsset,
46 const QuantLib::Handle<QuantLib::BlackVolTermStructure>& volTSShortAsset,
47 const QuantLib::Handle<QuantExt::CorrelationTermStructure>& rho,
48 Real beta = 0.0);
49 void calculate() const override;
50
51private:
53 Time tn;
54 Real atm;
55 Real sigma;
57 std::vector<QuantLib::Date> pricingDates;
58 std::vector<std::string> indexNames;
59 std::vector<Real> fixings;
60 std::vector<QuantLib::Date> expiries;
61 };
62
63 PricingParameter derivePricingParameterFromFlow(const ext::shared_ptr<CommodityCashFlow>& flow,
64 const ext::shared_ptr<BlackVolTermStructure>& vol,
65 const ext::shared_ptr<FxIndex>& fxIndex) const;
66
67 //! Return the correlation between two future expiry dates \p ed_1 and \p ed_2
68 double intraAssetCorrelation(const QuantLib::Date& e1, const QuantLib::Date& e2,
69 const ext::shared_ptr<BlackVolTermStructure>& vol) const;
70
71 double rho() const;
72
73protected:
74 QuantLib::Handle<QuantLib::YieldTermStructure> discountCurve_;
75 QuantLib::Handle<QuantLib::BlackVolTermStructure> volTSLongAsset_;
76 QuantLib::Handle<QuantLib::BlackVolTermStructure> volTSShortAsset_;
77 const QuantLib::Handle<QuantExt::CorrelationTermStructure> rho_;
78 QuantLib::Real beta_;
79};
80
81} // namespace QuantExt
wrapper around a vector of BS processes
base class for commodity spread option engines
const QuantLib::Handle< QuantExt::CorrelationTermStructure > rho_
QuantLib::Handle< QuantLib::BlackVolTermStructure > volTSShortAsset_
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
QuantLib::Handle< QuantLib::BlackVolTermStructure > volTSLongAsset_
double intraAssetCorrelation(const QuantLib::Date &e1, const QuantLib::Date &e2, const ext::shared_ptr< BlackVolTermStructure > &vol) const
Return the correlation between two future expiry dates ed_1 and ed_2.
PricingParameter derivePricingParameterFromFlow(const ext::shared_ptr< CommodityCashFlow > &flow, const ext::shared_ptr< BlackVolTermStructure > &vol, const ext::shared_ptr< FxIndex > &fxIndex) const
Term structure of correlations.
base class for multi path generators