# NOT RUN {
# Example 1
###Simulate a geometric Brownian motion (GBM) process:
## starting price of 20, with a growth of 5% p.a. and
## volatility of 20% p.a.
simulated_spot_prices <- spot_price_simulate(
x_0 = log(20),
parameters = c(mu_rn = (0.05 - (1/2) * 0.2^2), sigma_1 = 0.2),
t = 1,
dt = 1/12,
N_simulations = 1e3)
# Example 2
###Simulate future spot price paths under Risk-Neutrality and under the
###Schwartz - Smith two factor model:
##Step 1 - Run the Kalman Filter for the Two-Factor Oil Model:
SS_2F_filtered <- NFCP_Kalman_filter(parameter_values = SS_oil$two_factor,
parameter_names = names(SS_oil$two_factor),
log_futures = log(SS_oil$stitched_futures),
dt = SS_oil$dt,
futures_TTM = SS_oil$stitched_TTM,
verbose = TRUE)
#Step 2 - Simulate spot prices:
##100 antithetic simulations of one year of monthly observations
simulated_spot_prices <- spot_price_simulate(
x_0 = SS_2F_filtered$x_t,
parameters = SS_oil$two_factor,
t = 1,
dt = 1/12,
N_simulations = 1e3,
antithetic = TRUE,
verbose = TRUE)
# }
Run the code above in your browser using DataLab