Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
CommoditySchwartzParametrization Class Reference

COM Schwartz parametrization. More...

#include <qle/models/commodityschwartzparametrization.hpp>

+ Inheritance diagram for CommoditySchwartzParametrization:
+ Collaboration diagram for CommoditySchwartzParametrization:

Public Member Functions

 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)
 
Size numberOfParameters () const override
 
Real variance (const Time t) const
 State variable variance on [0, t]. More...
 
Real sigma (const Time t) const
 State variable Y's diffusion at time t: sigma * exp(kappa * t) More...
 
Real sigmaParameter () const
 Inspector for the current value of model parameter sigma (direct) More...
 
Real kappaParameter () const
 Inspector for the current value of model parameter kappa (direct) More...
 
const QuantLib::ext::shared_ptr< Parameter > parameter (const Size) const override
 Inspector for current value of the model parameter vector (inverse values) More...
 
Handle< QuantExt::PriceTermStructurepriceCurve ()
 Inspector for today's price curve. More...
 
Real VtT (Real t, Real T)
 Variance V(t,T) used in the computation of F(t,T) More...
 
bool driftFreeState () const
 
- Public Member Functions inherited from Parametrization
 Parametrization (const Currency &currency, const std::string &name="")
 
virtual ~Parametrization ()
 
virtual const Currency & currency () const
 
virtual const Array & parameterTimes (const Size) const
 
virtual Size numberOfParameters () const
 
virtual Array parameterValues (const Size) const
 
virtual const QuantLib::ext::shared_ptr< Parameter > parameter (const Size) const
 
virtual void update () const
 
const std::string & name () const
 
virtual Real direct (const Size, const Real x) const
 
virtual Real inverse (const Size, const Real y) const
 

Protected Member Functions

Real direct (const Size i, const Real x) const override
 
Real inverse (const Size i, const Real y) const override
 
- Protected Member Functions inherited from Parametrization
Time tr (const Time t) const
 
Time tl (const Time t) const
 
Time tr2 (const Time t) const
 
Time tm2 (const Time t) const
 
Time tl2 (const Time t) const
 

Private Attributes

const Handle< QuantExt::PriceTermStructurepriceCurve_
 
const Handle< Quote > fxSpotToday_
 
std::string comName_
 
const QuantLib::ext::shared_ptr< PseudoParametersigma_
 
const QuantLib::ext::shared_ptr< PseudoParameterkappa_
 
bool driftFreeState_
 

Additional Inherited Members

- Protected Attributes inherited from Parametrization
const Real h_
 
const Real h2_
 

Detailed Description

COM Schwartz parametrization.

COM parametrization for the Schwartz (1997) mean-reverting one-factor model with log-normal forward price dynamics and forward volatility sigma * exp(-kappa*(T-t)): dF(t,T) / F(t,T) = sigma * exp(-kappa * (T-t)) * dW

The model can be propagated in terms of an artificial spot price process of the form S(t) = A(t) * exp(B(t) * X(t)) where
dX(t) = -kappa * X(t) * dt + sigma * dW(t) X(t) - X(s) = -X(s) * (1 - exp(-kappa*(t-s)) + int_s^t sigma * exp(-kappa*(t-u)) dW(u) E[X(t)|s] = X(s) * exp(-kappa*(t-s)) Var[X(t)-X(s)|s] = sigma^2 * (1 - exp(-2*kappa*(t-s))) / (2*kappa)

The stochastic future price curve in terms of X(t) is F(t,T) = F(0,T) * exp( X(t) * exp(-kappa*(T-t) - 1/2 * (V(0,T) - V(t,T)) with V(t,T) = sigma^2 * (1 - exp(-2*kappa*(T-t))) / (2*kappa) and Var[ln F(T,T)] = VaR[X(T)]

Instead of state variable X we can use Y(t) = exp(kappa * t) * X(t) with drift-free dY(t) = sigma * exp(kappa * t) * dW Y(t) = int_0^t sigma * exp(kappa * s) * dW(s) Var[Y(t)] = sigma^2 * (exp(2*kappa*t) - 1) / (2*kappa) Var[Y(t)-Y(s)|s] = int_s^t sigma * exp(kappa * u) * dW(u) = Var[Y(t)] - Var[Y(s)] The stochastic future price curve in terms of Y(t) is F(t,T) = F(0,t) * exp( Y(t) * exp(-kappa*T) - 1/2 * (V(0,T) - V(t,T))

Definition at line 64 of file commodityschwartzparametrization.hpp.

Constructor & Destructor Documentation

◆ CommoditySchwartzParametrization()

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 
)

The currency refers to the commodity currency, the fx spot is as of today (i.e. the discounted spot)

Definition at line 24 of file commodityschwartzparametrization.cpp.

30 sigma_(QuantLib::ext::make_shared<PseudoParameter>(1)), kappa_(QuantLib::ext::make_shared<PseudoParameter>(1)),
32 sigma_->setParam(0, inverse(0, sigma));
33 kappa_->setParam(0, inverse(0, kappa));
34}
Real inverse(const Size i, const Real y) const override
Handle< QuantExt::PriceTermStructure > priceCurve()
Inspector for today's price curve.
const Handle< QuantExt::PriceTermStructure > priceCurve_
const QuantLib::ext::shared_ptr< PseudoParameter > sigma_
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)
const std::string & name() const
virtual const Currency & currency() const
Parametrization(const Currency &currency, const std::string &name="")
+ Here is the call graph for this function:

Member Function Documentation

◆ numberOfParameters()

Size numberOfParameters ( ) const
overridevirtual

the number of parameters in this parametrization

Reimplemented from Parametrization.

Definition at line 73 of file commodityschwartzparametrization.hpp.

73{ return 2; }

◆ variance()

Real variance ( const Time  t) const

State variable variance on [0, t].

Definition at line 111 of file commodityschwartzparametrization.hpp.

111 {
112 Real sig = direct(0, sigma_->params()[0]);
113 Real kap = direct(0, kappa_->params()[0]);
114 if (kap < QL_EPSILON)
115 return sig * sig * t;
116 else if (driftFreeState_)
117 return sig * sig * (std::exp(2.0 * kap * t) - 1.0) / (2.0 * kap);
118 else
119 return sig * sig * (1.0 - std::exp(-2.0 * kap * t)) / (2.0 * kap);
120}
Real direct(const Size i, const Real x) const override
+ Here is the call graph for this function:

◆ sigma()

Real sigma ( const Time  t) const

State variable Y's diffusion at time t: sigma * exp(kappa * t)

Definition at line 122 of file commodityschwartzparametrization.hpp.

122 {
123 Real sig = direct(0, sigma_->params()[0]);
124 Real kap = direct(0, kappa_->params()[0]);
125 if (driftFreeState_)
126 return sig * std::exp(kap * u);
127 else
128 return sig;
129}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sigmaParameter()

Real sigmaParameter ( ) const

Inspector for the current value of model parameter sigma (direct)

Definition at line 131 of file commodityschwartzparametrization.hpp.

131 {
132 return direct(0, sigma_->params()[0]);
133}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ kappaParameter()

Real kappaParameter ( ) const

Inspector for the current value of model parameter kappa (direct)

Definition at line 135 of file commodityschwartzparametrization.hpp.

135 {
136 return direct(0, kappa_->params()[0]);
137}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parameter()

const QuantLib::ext::shared_ptr< Parameter > parameter ( const Size  i) const
overridevirtual

Inspector for current value of the model parameter vector (inverse values)

Reimplemented from Parametrization.

Definition at line 139 of file commodityschwartzparametrization.hpp.

139 {
140 QL_REQUIRE(i < 2, "parameter " << i << " does not exist, only have 0 and 1");
141 if (i == 0)
142 return sigma_;
143 else
144 return kappa_;
145}

◆ priceCurve()

Handle< QuantExt::PriceTermStructure > priceCurve ( )

Inspector for today's price curve.

Definition at line 85 of file commodityschwartzparametrization.hpp.

85{ return priceCurve_; }

◆ VtT()

Real VtT ( Real  t,
Real  T 
)

Variance V(t,T) used in the computation of F(t,T)

Definition at line 36 of file commodityschwartzparametrization.cpp.

36 {
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}
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)
+ Here is the call graph for this function:

◆ driftFreeState()

bool driftFreeState ( ) const

Definition at line 89 of file commodityschwartzparametrization.hpp.

89{ return driftFreeState_; }

◆ direct()

Real direct ( const Size  Size,
const Real  x 
) const
overrideprotectedvirtual

transformations between raw and actual parameters

Reimplemented from Parametrization.

Definition at line 107 of file commodityschwartzparametrization.hpp.

107{ return x * x; }
+ Here is the caller graph for this function:

◆ inverse()

Real inverse ( const Size  i,
const Real  y 
) const
overrideprotectedvirtual

Reimplemented from Parametrization.

Definition at line 109 of file commodityschwartzparametrization.hpp.

109{ return std::sqrt(y); }
+ Here is the caller graph for this function:

Member Data Documentation

◆ priceCurve_

const Handle<QuantExt::PriceTermStructure> priceCurve_
private

Definition at line 97 of file commodityschwartzparametrization.hpp.

◆ fxSpotToday_

const Handle<Quote> fxSpotToday_
private

Definition at line 98 of file commodityschwartzparametrization.hpp.

◆ comName_

std::string comName_
private

Definition at line 99 of file commodityschwartzparametrization.hpp.

◆ sigma_

const QuantLib::ext::shared_ptr<PseudoParameter> sigma_
private

Definition at line 100 of file commodityschwartzparametrization.hpp.

◆ kappa_

const QuantLib::ext::shared_ptr<PseudoParameter> kappa_
private

Definition at line 101 of file commodityschwartzparametrization.hpp.

◆ driftFreeState_

bool driftFreeState_
private

Definition at line 102 of file commodityschwartzparametrization.hpp.