Description Usage Arguments Details Value References Examples
Simulate Futures price data with dynamics that follow the parameters of an N-factor model through Monte Carlo simulation.
1 | Futures.Price.Simulate(X.0, parameters, dt, N.obs, TTM, verbose = TRUE)
|
X.0 |
Initial values of the state vector. |
parameters |
A named vector of parameter values of a specified N-factor model. Function |
dt |
discrete time step of simulation |
N.obs |
The number of observations to simulate |
TTM |
A vector or matrix of the time to maturity of futures contracts to simulate. See details |
verbose |
|
The Futures.Price.Simulate
function simulates futures price data using the Kalman Filter algorithm, drawing from a normal
distribution for the shocks in the transition and measurement equations at each discrete time step. At each discrete time point,
an observation of the state vector is generated through the transition equation, drawing from a normal distribution with a covariance equal to \mjeqnQ_tQ[t].
Following this, simulated futures prices are generated through the measurement equation, drawing from a normal distribution with covariance matrix equal to \mjeqnHH.
Input TTM
can be either a matrix specifying the constant time to maturity of futures contracts to simulate, or it can be a matrix where nrow(TTM) == N.obs
for the time-varying time to maturity of the futures contracts to simulate. This allows for the simulation of both aggregate stitched data and individual futures contracts.
Futures.Price.Simulate
returns a list with three objects when verbose = T
and a matrix of simulated futures prices when verbose = F
. The list objects returned are:
State.Vector
A matrix
of Simulated state variables at each discrete time point. The columns represent each factor of the N-factor model and the rows represent
the simulated values at each discrete simulated time point.
Futures
A matrix
of Simulated futures prices, with each column representing a simulated futures contract.
Spot
A vector of simulated spot prices
Schwartz, E. S., and J. E. Smith, (2000). Short-Term Variations and Long-Term Dynamics in Commodity Prices. Manage. Sci., 46, 893-911.
Cortazar, G., and L. Naranjo, (2006). An N-factor Gaussian model of oil futures prices. Journal of Futures Markets: Futures, Options, and Other Derivative Products, 26(3), 243-268.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ##Example 1 - Simulate Crude Oil Stitched futures prices
##under a Two-Factor model, assuming a constant time to maturity:
Simulated.Stitched.Futures <- Futures.Price.Simulate(X.0 = c(log(SS.Oil$Spot[1,1]), 0),
parameters = SS.Oil$Two.Factor,
dt = SS.Oil$dt,
N.obs = nrow(SS.Oil$Stitched.Futures),
TTM = SS.Oil$Stitched.TTM)
##Example 2 - Simulate Crude Oil Contract Prices under a Two-Factor model
###Assume constant white noise in parameters of 1%:
SS.Oil.Two.Factor <- SS.Oil$Two.Factor
SS.Oil.Two.Factor <- SS.Oil.Two.Factor[!grepl("contract", names(SS.Oil.Two.Factor))]
SS.Oil.Two.Factor["sigma.contracts"] <- 0.01
Simulated.Contracts <- Futures.Price.Simulate(X.0 = c(log(SS.Oil$Spot[1,1]), 0),
parameters = SS.Oil.Two.Factor,
dt = SS.Oil$dt,
N.obs = nrow(SS.Oil$Contracts),
TTM = SS.Oil$Contract.Maturities)
##Not Run - plot Simulated prices:
# matplot(as.Date(rownames(SS.Oil$Contracts)), Simulated.Contracts$Futures, type = 'l')
# matplot(as.Date(rownames(SS.Oil$Contracts)), Simulated.Stitched.Futures$Futures, type = 'l')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.