# NOT RUN {
# Example 1 - An American put option on a futures contract following 'GBM'
American_option_value(x_0 = log(36),
parameters = c(mu_rn = 0.06, sigma_1 = 0.2),
N_simulations = 1e2,
futures_maturity = 1,
option_maturity = 1,
dt = 1/50,
K = 40,
r = 0.06,
verbose = FALSE,
orthogonal = "Laguerre",
degree = 3)
# Example 2 - An American put option under a two-factor crude oil model:
## Step 1 - Obtain current (i.e. most recent) state vector by filtering the
## two-factor oil model:
Schwartz_Smith_oil <- 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 - Calculate 'put' option price:
American_option_value(x_0 = Schwartz_Smith_oil$x_t,
parameters = SS_oil$two_factor,
futures_maturity = 2,
option_maturity = 1,
K = 20,
r = 0.05,
call = FALSE,
N_simulations = 1e2,
dt = 1/12,
verbose = TRUE,
orthogonal = "Power",
degree = 2)
# }
Run the code above in your browser using DataLab