Sei sulla pagina 1di 34

Commodity Modelling

Schwartz two-factor model


Philipp Erb IDP Winterthur David Lthi Clariden Leu Zrich
July 2, 2009
School of
Engineering
IDP Institute of
Data Analysis and
Process Design
Zurich University
of Applied Sciences
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
Inexible 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:
dS
t
= (
t
) S
t
dt +
S
S
t
dW
S
d
t
= (
t
) dt +

dW

dW
S
dW

= dt
The Q-dynamics:
dS
t
= (r
t
) S
t
dt +
S
S
t
d

W
S
d
t
= [(
t
) ] dt +

d

W

d

W
S
d

W

= 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 rst two moments:

Distribution under P and Q


_
X

_
= N
P

_
=
_

_
, =
_

2
X

X

X

2

__
,
_
X

_
= N
Q

_
=
_

X

_
, =
_

2
X

X

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:
G(S
0
,
0
, T) = E
Q
[S
T
] = e

X
+
1
2

2
X
= S
0
e
A(T)+B(T)
0
with
A(T) =
_
r +
1
2

2


S

_
T +
1
4

1 e
2T

3
+
_
+
S

_
1 e
T

2
,
B(T) =
e
T
1

IDP Winterthur, Clariden Leu Zrich


Commodity Modelling 12 / 33
Schwartz two-factor model in a nutshell
Futures
Ane term structure of futures prices:
log G(T) = X
0
+ B(T)
0
+ A(T)
Model can be cast in state space form
Both state variables (factors: X
t
,
t
) unobservable
Kalman lter
IDP Winterthur, Clariden Leu Zrich
Commodity Modelling 13 / 33
Schwartz two-factor model in a nutshell
European Options
Ane term structure of futures prices:
log G(T) = X
0
+ 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
= E
Q
_
e
r t
(G(S
t
,
t
, T t) K)
+

= P(0, t) {G(0, T)(d


+
) K(d

)}
with
d

=
log
G(0,T)
K

1
2

2
=
2
S
t +
2
S

_
1

e
T
_
e
t
1
_
t
_
+

2
_
t +
1
2
e
2T
_
e
2t
1
_

e
T
_
e
t
1
_
_
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
Ane term structure of futures prices:
log G(T) = X
0
+ B(T)
0
+ A(T)
Futures log-price Gaussian: log G N
_

G
,
2
G
_
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 xed point in time, the distribution is dened.
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
t2factor 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.
lter2factor 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:
(s
0
,
0
, ,
S
, , ,

, )
The transition density of the futures price depends on 10 parameter:
(s
0
,
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
= d
t
+ T
t

t
+ H
t

t
,
t
N(0, I
2
) (4.1)
Measurement equation:
Futures prices are measured. The log-futures price are an ane
function of the log-spot price and the convenience yield.
y
t
= c
t
+ Z
t

t
+ G
t

t
,
t
N(0, I
n
) (4.2)
IDP Winterthur, Clariden Leu Zrich
Commodity Modelling 24 / 33
Using schwartz97
State Space Model: Transition Equation

t+1
= d
t
+ T
t

t
+ H
t

t
,
t
N(0, I
2
) (4.3)

t+t
=
_
X
t+t

t+t
_
(4.4)
T
t
=
_
1
1

_
e
t
1
_
0 e
t
_
(4.5)
d
t
=
_
_
_

1
2

2
S

_
t +

_
1 e
t
_

_
1 e
t
_
_
_
(4.6)
H
t
H

t
=
_

2
X
(t)
X
(t)

X
(t)
2

(t),
_
(4.7)
where X
t
= log S
t
and t = t
k+1
t
k
.
IDP Winterthur, Clariden Leu Zrich
Commodity Modelling 25 / 33
Using schwartz97
State Space Model: Measurement Equation
y
t
= c
t
+ Z
t

t
+ G
t

t
,
t
N(0, I
n
) (4.8)
y
t
=
_
_
_
_
log G
t
(1)
.
.
.
log G
t
(n)
_
_
_
_
Z
t
=
_
_
_
_
1 B(m
t
(1))
.
.
.
.
.
.
1 B(m
t
(n))
_
_
_
_
(4.9)
c
t
=
_
_
_
_
A(m
t
(1))
.
.
.
A(m
t
(n))
_
_
_
_
G
t
G

t
=
_
_
_
_
g
2
11
.
.
.
g
2
nn
_
_
_
_
(4.10)
where m
t
(i ) denotes the remaining time to maturity of the i -th
closest to maturity futures G
t
(i ).
IDP Winterthur, Clariden Leu Zrich
Commodity Modelling 26 / 33
Using schwartz97
Function t2factor
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 t2factor
> 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 t2factor
> 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; (Number: 8)
log-Likelihood: 112485.1
Nbr. of iterations: 75
----------------------------------------------------------------
>
IDP Winterthur, Clariden Leu Zrich
Commodity Modelling 30 / 33
Using schwartz97
Function lter2factor
> filter2factor(copper$futures[!na.idx,], copper$ttm[!na.idx,], copper.fit)
>
0 1000 2000 3000 4000 5000
5
0
2
0
0
3
5
0
Index
Spot price
Closest to maturity futures
0 1000 2000 3000 4000 5000

0
.
1
0
.
2
0
.
5
Index
Convenience yield
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-o: 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

Potrebbero piacerti anche