Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityschwartzparametrization.cpp
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#include <ql/math/comparison.hpp>
21
22namespace QuantExt {
23
24CommoditySchwartzParametrization::CommoditySchwartzParametrization(const Currency& currency, const std::string& name,
25 const Handle<QuantExt::PriceTermStructure>& priceCurve,
26 const Handle<Quote>& fxSpotToday,
27 const Real sigma, const Real kappa,
28 bool driftFreeState)
29 : Parametrization(currency, name), priceCurve_(priceCurve), fxSpotToday_(fxSpotToday),
30 sigma_(QuantLib::ext::make_shared<PseudoParameter>(1)), kappa_(QuantLib::ext::make_shared<PseudoParameter>(1)),
31 driftFreeState_(driftFreeState) {
32 sigma_->setParam(0, inverse(0, sigma));
33 kappa_->setParam(0, inverse(0, kappa));
34}
35
37 Real sig = sigmaParameter();
38 Real kap = kappaParameter();
39 if (fabs(kap) < QL_EPSILON)
40 return sig * sig * (T-t);
41 else
42 return sig * sig * (1.0 - std::exp(-2.0 * kap * (T-t))) / (2.0 * kap);
43}
44
45} // namespace QuantExt
Real inverse(const Size i, const Real y) const override
Real VtT(Real t, Real T)
Variance V(t,T) used in the computation of F(t,T)
CommoditySchwartzParametrization(const Currency &currency, const std::string &name, const Handle< QuantExt::PriceTermStructure > &priceCurve, const Handle< Quote > &fxSpotToday, const Real sigma, const Real kappa, bool driftFreeState=false)
const QuantLib::ext::shared_ptr< PseudoParameter > sigma_
Real sigmaParameter() const
Inspector for the current value of model parameter sigma (direct)
Real kappaParameter() const
Inspector for the current value of model parameter kappa (direct)
const QuantLib::ext::shared_ptr< PseudoParameter > kappa_
Real sigma(const Time t) const
State variable Y's diffusion at time t: sigma * exp(kappa * t)
Parameter that accesses CalibratedModel.
Schwartz commodity model parametrization.
std::vector< bool > driftFreeState