Commodity Modelling: Schwartz Two-Factor Model

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

Zurich University

of Applied Sciences

School of
Engineering

IDP Institute of
Data Analysis and
Process Design

Commodity Modelling

Schwartz two-factor model

Philipp Erb IDP Winterthur David Lthi Clariden Leu Zrich

July 2, 2009
Commodity Modelling 1 / 33

Outline

1 Motivation

2 Commodity model types

3 Schwartz two-factor model in a nutshell


Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures

4 Using schwartz97
Parameter Estimation
Examples

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 2 / 33
Motivation

Motivation and Context

CTI project between IDP and FRSGlobal

Extending FRSGlobals softwaretool riskpro with commodity models

Schwartz fator model: Basic model


A Hinz model: More advanced model

Implementation of protoype models in R

No commodity models on CRAN so far


Launching commodity model package schwartz97

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 3 / 33
Commodity model types

Outline
1 Motivation
2 Commodity model types
3 Schwartz two-factor model in a nutshell
Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures
4 Using schwartz97
Parameter Estimation
Examples

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 4 / 33
Commodity model types

Commodity model types

Spot price models: E.g. Schwartz factor models

Few parameters
Inflexible term sturcutre of futures prices

Futures price models: E.g. HJM type model by Juri Hinz

Numerous parameters
Flexible term sturcture generic

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 5 / 33
Commodity model types

Schwartz factor models


One-factor model
Spot price Log-price mean-reverting (Ornstein-Uhlenbeck)

Two-factor model
Spot price Log-normal (Geometric Brownian motion)
Convenience yield Mean-reverting (Ornstein-Uhlenbeck)

Three-factor model
Spot price Log-normal (Geometric Brownian motion)
Convenience yield Mean-reverting (Ornstein-Uhlenbeck)
Interest rate Mean-reverting (Vasicek)

Empirical study: Two-factor model most-parsimonious choice

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 6 / 33
Schwartz two-factor model in a nutshell

Outline

1 Motivation

2 Commodity model types

3 Schwartz two-factor model in a nutshell


Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures

4 Using schwartz97
Parameter Estimation
Examples

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 7 / 33
Schwartz two-factor model in a nutshell

Model dynamics: Two-factor model


The P-dynamics:

dSt = ( t ) St dt + S St dWS

dt = ( t ) dt +  dW

dWS dW = dt

The Q-dynamics:

S
dSt = (r t ) St dt + S St d W

dt = [ ( t ) ] dt +  d W
SdW
dW  = dt

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 8 / 33
Schwartz two-factor model in a nutshell

Outline
1 Motivation
2 Commodity model types
3 Schwartz two-factor model in a nutshell
Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures
4 Using schwartz97
Parameter Estimation
Examples

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 9 / 33
Schwartz two-factor model in a nutshell

Joint distribution of state variables

Log-price X := log S and convenience yield joint normal


Solve SDE under P and Q and compute first two moments:
I Distribution under P and Q

      2 
X P X X X
=N = , = ,
X 2
      2 
X Q
X X X
=N = , =

X 2

Basic tool for all computations


(pricing, simulation, risk measures, calibration)

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 10 / 33
Schwartz two-factor model in a nutshell

Outline

1 Motivation

2 Commodity model types

3 Schwartz two-factor model in a nutshell


Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures

4 Using schwartz97
Parameter Estimation
Examples

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 11 / 33
Schwartz two-factor model in a nutshell

Futures
Futures prices:

1 2
G(S0 , 0 , T ) = EQ [ST ] = e X + 2 X

= S0 e A(T )+B(T )0

with
 
1 2 S  1 2 1 e 2T
A(T ) = r
+ T+ 
2 2 4 3
 
2 1 e T
+ + S 
,
2
e T 1
B(T ) =

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 12 / 33
Schwartz two-factor model in a nutshell

Futures

Affine term structure of futures prices:


log G(T ) = X0 + B(T )0 + A(T )
Model can be cast in state space form

Both state variables (factors: Xt , t ) unobservable


Kalman filter

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 13 / 33
Schwartz two-factor model in a nutshell

European Options

Affine term structure of futures prices:


log G(T ) = X0 + B(T )0 + A(T )

Futures prices log-normal

BS-type formulas for European options on futures

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 14 / 33
Schwartz two-factor model in a nutshell

European Options
European call option:
C G = EQ e r t (G(St , t , T t) K )+
 

= P(0, t) {G(0, T )(d+ ) K (d )}


with
G(0,T )
log K
21 2
d = ,

2
   
2 2 2S  1 T t
 1 2T 2t
 2 T t
= S t + e e 1 t + t+ e e 1 e e 1
2 2

Put-call parity:
C G P G = P(0, t) {G(0, t) K }
European put option:
P G = P(0, t) {K (d ) G(0, T )(d+ )}

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 15 / 33
Schwartz two-factor model in a nutshell

Outline
1 Motivation

2 Commodity model types

3 Schwartz two-factor model in a nutshell


Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures
4 Using schwartz97
Parameter Estimation
Examples

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 16 / 33
Schwartz two-factor model in a nutshell

Risk Measures

Affine term structure of futures prices:


log G(T ) = X0 + B(T )0 + A(T )
 
Futures log-price Gaussian: log G N G , G2

Losses (negative log-returns) Gaussian

Closed formulas for value at risk (VaR) and expected


shortfall (ES) for futures contracts

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 17 / 33
Using schwartz97

Outline
1 Motivation
2 Commodity model types
3 Schwartz two-factor model in a nutshell
Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures
4 Using schwartz97
Parameter Estimation
Examples

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 18 / 33
Using schwartz97

Function Overview: Usual d/p/q/r style

If all parameters are known, the transition density is known.


For a fixed point in time, the distribution is defined.

d/p/q/r-state d/p/q/r functions for the bivariate state variables.

simstate Generate trajectories from the state variables.

d/p/q/r-futures d/p/q/r functions for the log-normal futures prices.

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 19 / 33
Using schwartz97

Function Overview: Estimation, pricing, risk

fit2factor Fit parameters to data.

pricefutures Calculate futures prices.

priceoption Price a European call or put option written on a futures


contract.

VaR/ES-futures Value-at-risk and Expected-shortfall of futures prices.

filter2factor Filter a futures price series and obtain the state


variables.

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 20 / 33
Using schwartz97

Object Orientation
Problem: Many parameters involved
The transition density of the state variables depends on 8 parameter:
(s0 , 0 , , S , , ,  , )

The transition density of the futures price depends on 10 parameter:


(s0 , 0 , , S , , ,  , , , r )

Idea: 3 levels of encapsulation


Raw parameters.
schwartz2factor-class
fit.schwartz2factor-class

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 21 / 33
Using schwartz97

Example: dfutures

dfutures(x, ttm = 1, s0 = 50, delta0 = 0,


mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0,
sigmaE = 0.5, rho = 0.75, r = 0.05, lambda = 0,
alphaT = NULL, ...)

## S4 method for signature ANY, ANY, schwartz2factor:


dfutures(x, ttm = 1, s0, r = 0.05, lambda = 0,
alphaT = NULL, ...)

## S4 method for signature ANY, ANY, fit.schwartz2factor:


dfutures(x, ttm = 1, s0, ...)

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 22 / 33
Using schwartz97

Outline
1 Motivation

2 Commodity model types

3 Schwartz two-factor model in a nutshell


Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures

4 Using schwartz97
Parameter Estimation
Examples

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 23 / 33
Using schwartz97

State Space Representation

Transition equation:
The state variables are log-spot price and convenience yield.

t+1 = dt + Tt t + Ht t , t N (0, I2 ) (4.1)

Measurement equation:
Futures prices are measured. The log-futures price are an affine
function of the log-spot price and the convenience yield.

yt = ct + Zt t + Gt t , t N (0, In ) (4.2)

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 24 / 33
Using schwartz97

State Space Model: Transition Equation

t+1 = dt + Tt t + Ht t , t N (0, I2 ) (4.3)

!
Xt+t
t+t = (4.4)
t+t
 !
1 1
e t 1
Tt = (4.5)
0 e t
   
12 S2 t +
1 e t
dt =  (4.6)
1 e t
!
0 X2 (t) X (t)
Ht Ht = (4.7)
X (t) 2 (t),
where Xt = log St and t = tk+1 tk .
IDP Winterthur, Clariden Leu Zrich
Commodity Modelling 25 / 33
Using schwartz97

State Space Model: Measurement Equation

yt = ct + Zt t + Gt t , t N (0, In ) (4.8)


log Gt (1) 1 B(mt (1))
.. .
. ..
yt =
.
Zt =
. .
(4.9)
log Gt (n) 1 B(mt (n))

A(mt (1)) 2
g11
.
..
0 ..
ct =

Gt G =
t .
(4.10)
A(mt (n)) 2
gnn
where mt (i) denotes the remaining time to maturity of the i-th
closest to maturity futures Gt (i).

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 26 / 33
Using schwartz97

Function fit2factor

fit2factor(data, ttm, deltat = 1 / 260,


s0 = data[1,1], delta0 = 0,
mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0, sigmaE = 0.5,
rho = 0.75, lambda = 0,
meas.sd = rep(0.02, ncol(data)),
opt.pars = c(s0 = FALSE, delta0 = FALSE, mu = TRUE, sigmaS = TRUE,
kappa = TRUE, alpha = TRUE, sigmaE = TRUE,
rho = TRUE, lambda = TRUE),
opt.meas.sd = c("scalar", "all", "none"),
r = 0.05, silent = FALSE, ...)

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 27 / 33
Using schwartz97

Outline
1 Motivation
2 Commodity model types
3 Schwartz two-factor model in a nutshell
Model dynamics
Joint distribution of state variables
Pricing of basic derivatives
Risk measures
4 Using schwartz97
Parameter Estimation
Examples
IDP Winterthur, Clariden Leu Zrich
Commodity Modelling 28 / 33
Using schwartz97

Function fit2factor

> library(schwartz97)
Loading required package: FKF
Loading required package: mvtnorm
> data(futures)
> na.idx <- apply(is.na(copper$futures), 1, any)
> copper.fit <- fit2factor(copper$futures[!na.idx,], copper$ttm[!na.idx,],
+ control = list(maxit = 100, reltol = 1e-3),
+ silent = TRUE)
>

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 29 / 33
Using schwartz97

Function fit2factor
> copper.fit
----------------------------------------------------------------
Fitted Schwartz97 2 factor model:
d S_t = S_t * (mu - delta_t) * dt + S_t * sigmaS * dW_1
d delta_t = kappa * (alpha - delta_t) * dt + sigmaE * dW_2
E(dW_1 * dW_2) = rho * dt
s0 : 109.375364269883
delta0: 0
mu : 0.212827842930593
sigmaS: 0.37460428511304
kappa : 1.10747274866091
alpha : 0.0595560374598207
sigmaE: 0.474809676990843
rho : 0.813002684142751
r : 0.05
lambda: 0.0402214875501909
alphaT: 0.0232377735577751
----------------------------------------------------------------
Optimization information
Converged: TRUE
Fitted parameters: mu, sigmaS, kappa, alpha, sigmaE, rho, lambda, meas.sd1; (Num
log-Likelihood: 112485.1
Nbr. of iterations: 75
----------------------------------------------------------------
>

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 30 / 33
Using schwartz97

Function filter2factor
> filter2factor(copper$futures[!na.idx,], copper$ttm[!na.idx,], copper.fit)
>
350

Spot price
Closest to maturity futures
200
50

0 1000 2000 3000 4000 5000

Index
0.5

Convenience yield
0.2
0.1

0 1000 2000 3000 4000 5000

Index
IDP Winterthur, Clariden Leu Zrich
Commodity Modelling 31 / 33
Using schwartz97

Derivatives

> pricefutures(ttm = 3, copper.fit)


[1] 107.1682
> priceoption("call", time = 2, Time = 3, K = 110, copper.fit)
[1] 12.33399
>

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 32 / 33
Using schwartz97

Conclusion & Outlook

Conclusion

(Optimal??) trade-off: Statistical tractability vs. sophistication.


Stylized model.
First step towards commodity modelling in R.

Outlook
Implementing term-structure models (Juri Hinz & Max Fehr, 2007).

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 33 / 33
Using schwartz97

References

Rajna Gibson and Eduardo S. Schwartz.


Stochastic convenience yield and the pricing of oil contingent claims.
The Journal of Finance, 45(3):959976, 1990.
Eduardo S. Schwartz.
The stochastic behavior of commodity prices: Implications for valuation and
hedging.
Journal of Finance, 52(3):923973, 1997.
Kristian R. Miltersen and Eduardo S. Schwartz.
Pricing of options on commodity futures with stochastic term structures of
convenience yields and interest rates.
Journal of Financial and Quantitative Analysis, 33:3359, 1998.

IDP Winterthur, Clariden Leu Zrich

You might also like