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

#include <qle/models/commodityschwartzmodel.hpp>

+ Inheritance diagram for CommoditySchwartzModel:
+ Collaboration diagram for CommoditySchwartzModel:

Public Types

enum class  Discretization { Euler , Exact }
 

Public Member Functions

 CommoditySchwartzModel (const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > &parametrization, const Discretization discretization=Discretization::Euler)
 
const QuantLib::ext::shared_ptr< ParametrizationparametrizationBase () const override
 
Handle< PriceTermStructuretermStructure () const override
 
const Currency & currency () const override
 
Size n () const override
 
Size m () const override
 
QuantLib::ext::shared_ptr< StochasticProcessstateProcess () const override
 
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 QuantLib::ext::shared_ptr< CommoditySchwartzParametrizationparametrization () const
 Schwartz model specific methods. More...
 
void update () override
 observer and linked calibrated model interface More...
 
void generateArguments () override
 
virtual const QuantLib::ext::shared_ptr< ParametrizationparametrizationBase () const =0
 
virtual Handle< PriceTermStructuretermStructure () const =0
 
virtual const Currency & currency () const =0
 
virtual Size n () const =0
 
virtual Size m () const =0
 
virtual QuantLib::ext::shared_ptr< StochasticProcessstateProcess () const =0
 
virtual 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 =0
 
- Public Member Functions inherited from LinkableCalibratedModel
 LinkableCalibratedModel ()
 
void update () override
 
virtual void calibrate (const std::vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >(), const std::vector< bool > &fixParameters=std::vector< bool >())
 Calibrate to a set of market instruments (usually caps/swaptions) More...
 
virtual void calibrate (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >(), const std::vector< bool > &fixParameters=std::vector< bool >())
 for backward compatibility More...
 
Real value (const Array &params, const std::vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &)
 
Real value (const Array &params, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &)
 for backward compatibility More...
 
const QuantLib::ext::shared_ptr< Constraint > & constraint () const
 
EndCriteria::Type endCriteria () const
 Returns end criteria result. More...
 
const Array & problemValues () const
 Returns the problem values. More...
 
Array params () const
 Returns array of arguments on which calibration is done. More...
 
virtual void setParams (const Array &params)
 
virtual void setParam (Size idx, const Real value)
 

Private Attributes

QuantLib::ext::shared_ptr< CommoditySchwartzParametrizationparametrization_
 
Discretization discretization_
 
QuantLib::ext::shared_ptr< StochasticProcessstateProcess_
 

Additional Inherited Members

virtual void generateArguments ()
 
- Protected Attributes inherited from LinkableCalibratedModel
std::vector< QuantLib::ext::shared_ptr< Parameter > > arguments_
 
QuantLib::ext::shared_ptr< Constraintconstraint_
 
EndCriteria::Type endCriteria_
 
Array problemValues_
 

Detailed Description

Schwartz (1997) one-factor model of the commodity price termstructure with two constant parameters, sigma and kappa

Price curve dynamics (Martingale) dF(t,T) / F(t,T) = sigma * exp(-kappa * (T-t)) * dW

Model-implied price curve: 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 dX(t) = -kappa * X(t) * dt + sigma * dW(t), X(0) = 0

In terms of drift-free state variable Y(t) = exp(kappa*t) * X(t): F(t,T) = F(0,T) * exp{ Y(t) * exp(-kappa*T)) - 1/2 * (V(0,T)-V(t,T)) }, dY(t) = sigma * exp(kappa * t) dW(t), Y(0) = 0

Definition at line 52 of file commodityschwartzmodel.hpp.

Member Enumeration Documentation

◆ Discretization

enum class Discretization
strong

Constructor & Destructor Documentation

◆ CommoditySchwartzModel()

CommoditySchwartzModel ( const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > &  parametrization,
const Discretization  discretization = Discretization::Euler 
)

Definition at line 24 of file commodityschwartzmodel.cpp.

27 QL_REQUIRE(parametrization_ != nullptr, "CommoditySchwartzModel: parametrization is null");
28 arguments_.resize(2);
29 arguments_[0] = parametrization_->parameter(0);
30 arguments_[1] = parametrization_->parameter(1);
31 stateProcess_ = QuantLib::ext::make_shared<CommoditySchwartzStateProcess>(parametrization_, discretization_);
32}
QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > parametrization_
const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > parametrization() const
Schwartz model specific methods.
QuantLib::ext::shared_ptr< StochasticProcess > stateProcess_
std::vector< QuantLib::ext::shared_ptr< Parameter > > arguments_

Member Function Documentation

◆ parametrizationBase()

const QuantLib::ext::shared_ptr< Parametrization > parametrizationBase ( ) const
overridevirtual

parametrization (as base class)

Implements CommodityModel.

Definition at line 61 of file commodityschwartzmodel.hpp.

61{ return parametrization_; }

◆ termStructure()

Handle< PriceTermStructure > termStructure ( ) const
overridevirtual

price term structure to which the model is (initially) calibrated

Implements CommodityModel.

Definition at line 63 of file commodityschwartzmodel.hpp.

63{ return parametrization_->priceCurve(); }

◆ currency()

const Currency & currency ( ) const
overridevirtual

currency of the commodity

Implements CommodityModel.

Definition at line 65 of file commodityschwartzmodel.hpp.

65{ return parametrization_->currency(); }

◆ n()

Size n ( ) const
overridevirtual

dimension of model state

Implements CommodityModel.

Definition at line 67 of file commodityschwartzmodel.hpp.

67{ return 1; }

◆ m()

Size m ( ) const
overridevirtual

number of Brownians to evolve the state

Implements CommodityModel.

Definition at line 68 of file commodityschwartzmodel.hpp.

68{ return 1; }

◆ stateProcess()

QuantLib::ext::shared_ptr< StochasticProcess > stateProcess ( ) const
overridevirtual

stochastic process, this has dimension n() and m() Brownian drivers

Implements CommodityModel.

Definition at line 70 of file commodityschwartzmodel.hpp.

70{ return stateProcess_; }

◆ forwardPrice()

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
overridevirtual

stochastic forward price curve F(t,T) at future time t depending on state (of dimension n())

Implements CommodityModel.

Definition at line 34 of file commodityschwartzmodel.cpp.

35 {
36 QL_REQUIRE(T >= t && t >= 0.0, "T(" << T << ") >= t(" << t << ") >= 0 required in CommoditySchwartzModel::forwardPrice");
37 Real f0T = priceCurve.empty() ? parametrization_->priceCurve()->price(T) : priceCurve->price(T);
38 Real VtT = parametrization_->VtT(t, T);
39 Real V0T = parametrization_->VtT(0, T);
40 Real k = parametrization_->kappaParameter();
41 if (parametrization_->driftFreeState())
42 return f0T * std::exp(-state[0] * std::exp(-k*T) - 0.5 * (V0T - VtT));
43 else
44 return f0T * std::exp(-state[0] * std::exp(-k*(T-t)) - 0.5 * (V0T - VtT));
45}

◆ parametrization()

const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > parametrization ( ) const

Schwartz model specific methods.

Definition at line 77 of file commodityschwartzmodel.hpp.

77{ return parametrization_; }

◆ update()

void update ( )
override

observer and linked calibrated model interface

Definition at line 47 of file commodityschwartzmodel.cpp.

47 {
48 parametrization_->update();
49 notifyObservers();
50}
+ Here is the caller graph for this function:

◆ generateArguments()

void generateArguments ( )
overridevirtual

Reimplemented from LinkableCalibratedModel.

Definition at line 52 of file commodityschwartzmodel.cpp.

52{ update(); }
void update() override
observer and linked calibrated model interface
+ Here is the call graph for this function:

Member Data Documentation

◆ parametrization_

QuantLib::ext::shared_ptr<CommoditySchwartzParametrization> parametrization_
private

Definition at line 84 of file commodityschwartzmodel.hpp.

◆ discretization_

Discretization discretization_
private

Definition at line 85 of file commodityschwartzmodel.hpp.

◆ stateProcess_

QuantLib::ext::shared_ptr<StochasticProcess> stateProcess_
private

Definition at line 86 of file commodityschwartzmodel.hpp.