Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityschwartzmodel.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 commodityschwartzmodel.hpp
20 \brief Schwartz (1997) one-factor model of the commodity price termstructure
21 \ingroup models
22*/
23
24#pragma once
25
30
31#include <ql/math/comparison.hpp>
32
33namespace QuantExt {
34
35/*! Schwartz (1997) one-factor model of the commodity price termstructure
36 with two constant parameters, sigma and kappa
37
38 Price curve dynamics (Martingale)
39 dF(t,T) / F(t,T) = sigma * exp(-kappa * (T-t)) * dW
40
41 Model-implied price curve:
42 F(t,T) = F(0,T) * exp{ X(t) * exp(-kappa*(T-t))) - 1/2 * (V(0,T)-V(t,T)) },
43 with
44 V(t,T) = sigma^2 * (1 - exp(-2*kappa*(T-t))) / (2*kappa),
45 and
46 dX(t) = -kappa * X(t) * dt + sigma * dW(t), X(0) = 0
47
48 In terms of drift-free state variable Y(t) = exp(kappa*t) * X(t):
49 F(t,T) = F(0,T) * exp{ Y(t) * exp(-kappa*T)) - 1/2 * (V(0,T)-V(t,T)) },
50 dY(t) = sigma * exp(kappa * t) dW(t), Y(0) = 0
51*/
53public:
54 enum class Discretization { Euler, Exact };
55
56 CommoditySchwartzModel(const QuantLib::ext::shared_ptr<CommoditySchwartzParametrization>& parametrization,
57 const Discretization discretization = Discretization::Euler);
58
59 // CommodityModel interface
60
61 const QuantLib::ext::shared_ptr<Parametrization> parametrizationBase() const override { return parametrization_; }
62
63 Handle<PriceTermStructure> termStructure() const override { return parametrization_->priceCurve(); }
64
65 const Currency& currency() const override { return parametrization_->currency(); }
66
67 Size n() const override { return 1; }
68 Size m() const override { return 1; }
69
70 QuantLib::ext::shared_ptr<StochasticProcess> stateProcess() const override { return stateProcess_; }
71
72 QuantLib::Real forwardPrice(const QuantLib::Time t, const QuantLib::Time T, const QuantLib::Array& x,
73 const QuantLib::Handle<QuantExt::PriceTermStructure>& priceCurve
74 = QuantLib::Handle<QuantExt::PriceTermStructure>()) const override;
75
76 //! Schwartz model specific methods
77 const QuantLib::ext::shared_ptr<CommoditySchwartzParametrization> parametrization() const { return parametrization_; }
78
79 //! observer and linked calibrated model interface
80 void update() override;
81 void generateArguments() override;
82
83private:
84 QuantLib::ext::shared_ptr<CommoditySchwartzParametrization> parametrization_;
86 QuantLib::ext::shared_ptr<StochasticProcess> stateProcess_;
87};
88
89} // namespace QuantExt
QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > parametrization_
const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > parametrization() const
Schwartz model specific methods.
const QuantLib::ext::shared_ptr< Parametrization > parametrizationBase() const override
QuantLib::ext::shared_ptr< StochasticProcess > stateProcess() const override
void update() override
observer and linked calibrated model interface
QuantLib::ext::shared_ptr< StochasticProcess > stateProcess_
QuantLib::Real forwardPrice(const QuantLib::Time t, const QuantLib::Time T, const QuantLib::Array &x, const QuantLib::Handle< QuantExt::PriceTermStructure > &priceCurve=QuantLib::Handle< QuantExt::PriceTermStructure >()) const override
const Currency & currency() const override
Handle< PriceTermStructure > termStructure() const override
Commodity model base class.
Schwartz commodity model parametrization.
Hull White n factor parametrization.
ir model base class