Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

futures_price_simulate

Simulate futures prices of an N-factor model through Monte Carlo simulation


Description

Simulate Futures price data with dynamics that follow the parameters of an N-factor model through Monte Carlo simulation.

Usage

futures_price_simulate(
  x_0,
  parameters,
  dt,
  N_obs,
  futures_TTM,
  ME_TTM = NULL,
  verbose = TRUE
)

Arguments

x_0

Initial values of the state vector.

parameters

A named vector of parameter values of a specified N-factor model. Function NFCP_parameters is recommended.

dt

discrete time step of simulation

N_obs

The number of observations to simulate

futures_TTM

A vector or matrix of the time to maturity of futures contracts to simulate. See details

ME_TTM

vector of maturity groupings to consider for simulated futures prices. The length of ME_TTM must be equal to the number of 'ME' parameter values.

verbose

logical. Should the simulated state variables and associated prices be output?

Details

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 \(Q_t\). Following this, simulated futures prices are generated through the measurement equation, drawing from a normal distribution with covariance matrix equal to \(H\).

Input futures_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(futures_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.

Value

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_prices A matrix of Simulated futures prices, with each column representing a simulated futures contract.
spot_prices A vector of simulated spot prices

References

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.

Examples

##Example 1 - Simulate Crude Oil Stitched futures prices
##under a Two-Factor model, assuming a constant time to maturity:

simulated_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),
                                           futures_TTM = SS_oil$stitched_TTM)

##Example 2 - Simulate Crude Oil Contract Prices under a Two-Factor model,
##using a rolling-window of measurement errors:

simulated_futures_prices <- 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),
                                                  futures_TTM = SS_oil$contract_maturities,
                                                  ME_TTM = c(1/4, 1/2, 1, 2, 5))

NFCP

N-Factor Commodity Pricing Through Term Structure Estimation

v1.0.1
GPL-3
Authors
Thomas Aspinall [aut, cre] (<https://orcid.org/0000-0002-6968-1989>), Adrian Gepp [aut] (<https://orcid.org/0000-0003-1666-5501>), Geoff Harris [aut] (<https://orcid.org/0000-0003-4284-8619>), Simone Kelly [aut] (<https://orcid.org/0000-0002-6528-8557>), Colette Southam [aut] (<https://orcid.org/0000-0001-7263-2347>), Bruce Vanstone [aut] (<https://orcid.org/0000-0002-3977-2468>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.