Financial options based on scalar geometric Brownian motion and Heston models, similar to Mike Giles' original 2008 Operations Research paper, Giles (2008), using an Euler-Maruyama discretisation
Value
A named list containing:
sums
is a vector of length six \(\left(\sum Y_i, \sum Y_i^2, \sum Y_i^3, \sum Y_i^4, \sum X_i, \sum X_i^2\right)\) where \(Y_i\) are iid simulations with expectation \(E[P_0]\) when \(l=0\) and expectation \(E[P_l-P_{l-1}]\) when \(l>0\), and \(X_i\) are iid simulations with expectation \(E[P_l]\). Note that only the first two components of this are used by the main
mlmc()
driver, the full vector is used bymlmc.test()
for convergence tests etc;cost
is a scalar with the total cost of the paths simulated, computed as \(N \times 4^l\) for level \(l\).
References
Giles, M.B. (2008) 'Multilevel Monte Carlo Path Simulation', Operations Research, 56(3), pp. 607–617. Available at: doi:10.1287/opre.1070.0496 .
Author
Louis Aslett <louis.aslett@durham.ac.uk>
Mike Giles <Mike.Giles@maths.ox.ac.uk>
Tigran Nagapetyan <nagapetyan@stats.ox.ac.uk>
Examples
# \donttest{
# These are similar to the MLMC tests for the original
# 2008 Operations Research paper, using an Euler-Maruyama
# discretisation with 4^l timesteps on level l.
#
# The differences are:
# -- the plots do not have the extrapolation results
# -- two plots are log_2 rather than log_4
# -- the new MLMC driver is a little different
# -- switch to X_0=100 instead of X_0=1
#
# Note the following takes quite a while to run, for a toy example see after
# this block.
N0 <- 1000 # initial samples on coarse levels
Lmin <- 2 # minimum refinement level
Lmax <- 6 # maximum refinement level
test.res <- list()
for(option in 1:5) {
if(option == 1) {
cat("\n ---- Computing European call ---- \n")
N <- 1000000 # samples for convergence tests
L <- 5 # levels for convergence tests
Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1)
} else if(option == 2) {
cat("\n ---- Computing Asian call ---- \n")
N <- 1000000 # samples for convergence tests
L <- 5 # levels for convergence tests
Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1)
} else if(option == 3) {
cat("\n ---- Computing lookback call ---- \n")
N <- 1000000 # samples for convergence tests
L <- 5 # levels for convergence tests
Eps <- c(0.01, 0.02, 0.05, 0.1, 0.2)
} else if(option == 4) {
cat("\n ---- Computing digital call ---- \n")
N <- 4000000 # samples for convergence tests
L <- 5 # levels for convergence tests
Eps <- c(0.02, 0.05, 0.1, 0.2, 0.5)
} else if(option == 5) {
cat("\n ---- Computing Heston model ---- \n")
N <- 2000000 # samples for convergence tests
L <- 5 # levels for convergence tests
Eps <- c(0.005, 0.01, 0.02, 0.05, 0.1)
}
test.res[[option]] <- mlmc.test(opre_l, N, L, N0, Eps, Lmin, Lmax, option = option)
# print exact analytic value, based on S0=K
T <- 1
r <- 0.05
sig <- 0.2
K <- 100
k <- 0.5*sig^2/r;
d1 <- (r+0.5*sig^2)*T / (sig*sqrt(T))
d2 <- (r-0.5*sig^2)*T / (sig*sqrt(T))
if(option == 1) {
val <- K*( pnorm(d1) - exp(-r*T)*pnorm(d2) )
} else if(option == 2) {
val <- NA
} else if(option == 3) {
val <- K*( pnorm(d1) - pnorm(-d1)*k - exp(-r*T)*(pnorm(d2) - pnorm(d2)*k) )
} else if(option == 4) {
val <- K*exp(-r*T)*pnorm(d2)
} else if(option == 5) {
val <- NA
}
if(is.na(val)) {
cat(sprintf("\n Exact value unknown, MLMC value: %f \n", test.res[[option]]$P[1]))
} else {
cat(sprintf("\n Exact value: %f, MLMC value: %f \n", val, test.res[[option]]$P[1]))
}
# plot results
plot(test.res[[option]])
}
#>
#> ---- Computing European call ----
#>
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 1e+06 samples ***
#> **********************************************************
#>
#> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost
#> ---------------------------------------------------------------------------------------
#> 0 1.0225e+01 1.0225e+01 1.6140e+02 1.6140e+02 0.0000e+00 0.0000e+00 1.0000e+00
#> 1 2.1300e-01 1.0416e+01 4.4386e+00 2.0116e+02 2.0359e+01 2.4583e-01 4.0000e+00
#> 2 3.0142e-02 1.0443e+01 1.0682e+00 2.1343e+02 1.2848e+01 3.8346e-02 1.6000e+01
#> 3 5.6439e-03 1.0436e+01 2.7167e-01 2.1522e+02 7.6217e+00 1.4220e-01 6.4000e+01
#> 4 1.0348e-03 1.0459e+01 6.9123e-02 2.1671e+02 6.3099e+00 2.5154e-01 2.5600e+02
#> 5 5.4423e-04 1.0441e+01 1.7231e-02 2.1604e+02 5.9106e+00 2.1656e-01 1.0240e+03
#>
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#>
#> alpha = 2.208927 (exponent for MLMC weak convergence)
#> beta = 1.996768 (exponent for MLMC variance)
#> gamma = 2.000000 (exponent for MLMC cost)
#>
#> *****************************
#> *** MLMC complexity tests ***
#> *****************************
#>
#> eps value mlmc_cost std_cost savings N_l
#> -----------------------------------------------------------
#> 0.0050 1.0444e+01 4.649e+07 2.959e+09 63.64 19982970 1663468 409221 102841 26282
#> 0.0100 1.0438e+01 8.422e+06 1.837e+08 21.81 4251529 354397 85970 21517
#> 0.0200 1.0456e+01 2.123e+06 4.591e+07 21.63 1067991 87921 21861 5521
#> 0.0500 1.0396e+01 2.416e+05 1.821e+06 7.54 141217 13256 2963
#> 0.1000 1.0445e+01 6.352e+04 4.553e+05 7.17 35109 3102 1000
#>
#>
#> Exact value: 10.450584, MLMC value: 10.444362
#>
#> ---- Computing Asian call ----
#>
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 1e+06 samples ***
#> **********************************************************
#>
#> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost
#> ---------------------------------------------------------------------------------------
#> 0 5.1068e+00 5.1068e+00 4.0327e+01 4.0327e+01 0.0000e+00 0.0000e+00 1.0000e+00
#> 1 5.9794e-01 5.7065e+00 1.5850e+01 5.7667e+01 4.8820e+00 3.2165e-02 4.0000e+00
#> 2 4.9532e-02 5.7497e+00 1.4223e+00 6.2082e+01 5.9670e+00 1.2643e-01 1.6000e+01
#> 3 5.0397e-03 5.7722e+00 1.5257e-01 6.3261e+01 6.1551e+00 3.5811e-01 6.4000e+01
#> 4 1.1640e-03 5.7537e+00 2.4858e-02 6.3307e+01 5.9880e+00 4.0786e-01 2.5600e+02
#> 5 2.1230e-04 5.7639e+00 5.3853e-03 6.3626e+01 5.6941e+00 2.0749e-01 1.0240e+03
#>
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#>
#> alpha = 2.833053 (exponent for MLMC weak convergence)
#> beta = 2.888474 (exponent for MLMC variance)
#> gamma = 2.000000 (exponent for MLMC cost)
#>
#> *****************************
#> *** MLMC complexity tests ***
#> *****************************
#>
#> eps value mlmc_cost std_cost savings N_l
#> -----------------------------------------------------------
#> 0.0050 5.7646e+00 2.729e+07 2.159e+08 7.91 7655860 2406902 360400 66221
#> 0.0100 5.7467e+00 6.825e+06 5.398e+07 7.91 1912554 602189 90182 16571
#> 0.0200 5.7810e+00 1.709e+06 1.350e+07 7.90 479306 149650 22718 4175
#> 0.0500 5.7230e+00 1.956e+05 5.298e+05 2.71 65724 20500 2990
#> 0.1000 5.6500e+00 5.200e+04 1.324e+05 2.55 16025 4993 1000
#>
#>
#> Exact value unknown, MLMC value: 5.764555
#>
#> ---- Computing lookback call ----
#>
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 1e+06 samples ***
#> **********************************************************
#>
#> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost
#> ---------------------------------------------------------------------------------------
#> 0 2.0655e+01 2.0655e+01 1.7531e+02 1.7531e+02 0.0000e+00 0.0000e+00 1.0000e+00
#> 1 -2.5126e+00 1.8139e+01 1.3973e+01 1.9931e+02 4.5082e+00 3.3656e-02 4.0000e+00
#> 2 -6.8917e-01 1.7464e+01 4.8781e+00 2.0900e+02 3.9911e+00 1.4922e-01 1.6000e+01
#> 3 -1.7874e-01 1.7256e+01 1.4370e+00 2.1157e+02 3.7921e+00 3.2822e-01 6.4000e+01
#> 4 -4.4906e-02 1.7241e+01 3.8719e-01 2.1320e+02 3.7138e+00 3.4186e-01 2.5600e+02
#> 5 -1.1632e-02 1.7229e+01 1.0042e-01 2.1343e+02 3.6632e+00 1.2626e-03 1.0240e+03
#>
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#>
#> alpha = 1.944965 (exponent for MLMC weak convergence)
#> beta = 1.789603 (exponent for MLMC variance)
#> gamma = 2.000000 (exponent for MLMC cost)
#>
#> *****************************
#> *** MLMC complexity tests ***
#> *****************************
#>
#> eps value mlmc_cost std_cost savings N_l
#> -----------------------------------------------------------
#> 0.0100 1.7222e+01 4.765e+07 2.914e+09 61.15 10554014 1487827 440827 119886 30901 8310
#> 0.0200 1.7237e+01 1.194e+07 7.285e+08 61.00 2643654 372982 110106 29862 7780 2092
#> 0.0500 1.7165e+01 1.892e+06 1.166e+08 61.61 420456 58811 17380 4908 1212 326
#> 0.1000 1.6962e+01 4.433e+05 2.914e+07 65.74 101158 14254 4198 1125 258 78
#> 0.2000 1.7408e+01 5.640e+04 4.513e+05 8.00 17345 2453 1000 207
#>
#>
#> Exact value: 17.216802, MLMC value: 17.222393
#>
#> ---- Computing digital call ----
#>
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 4e+06 samples ***
#> **********************************************************
#>
#> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost
#> ---------------------------------------------------------------------------------------
#> 0 5.6943e+01 5.6943e+01 2.1741e+03 2.1741e+03 0.0000e+00 0.0000e+00 1.0000e+00
#> 1 -2.7954e+00 5.4125e+01 2.5809e+02 2.2190e+03 3.2059e+01 1.3674e-01 4.0000e+00
#> 2 -6.9818e-01 5.3471e+01 1.6582e+02 2.2272e+03 5.4104e+01 2.7114e-01 1.6000e+01
#> 3 -1.7177e-01 5.3314e+01 8.5629e+01 2.2290e+03 1.0556e+02 9.8189e-02 6.4000e+01
#> 4 -4.2758e-02 5.3243e+01 4.3557e+01 2.2298e+03 2.0771e+02 1.8516e-01 2.5600e+02
#> 5 -9.1318e-03 5.3243e+01 2.1856e+01 2.2298e+03 4.1399e+02 5.7742e-02 1.0240e+03
#>
#> WARNING: kurtosis on finest level = 413.989826
#> indicates MLMC correction dominated by a few rare paths;
#> for information on the connection to variance of sample variances,
#> see http://mathworld.wolfram.com/SampleVarianceDistribution.html
#>
#>
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#>
#> alpha = 2.054519 (exponent for MLMC weak convergence)
#> beta = 0.905215 (exponent for MLMC variance)
#> gamma = 2.000000 (exponent for MLMC cost)
#>
#> *****************************
#> *** MLMC complexity tests ***
#> *****************************
#>
#> eps value mlmc_cost std_cost savings N_l
#> -----------------------------------------------------------
#> 0.0200 5.3238e+01 7.198e+08 7.611e+09 10.57 72212192 12465191 4976067 1809513 638892 233175
#> 0.0500 5.3243e+01 5.106e+07 3.044e+08 5.96 7693372 1323219 532130 187664 68565
#> 0.1000 5.3226e+01 1.302e+07 7.611e+07 5.84 1942663 334172 130755 47694 17964
#> 0.2000 5.3301e+01 1.442e+06 4.755e+06 3.30 323329 55831 22220 8442
#> 0.5000 5.3518e+01 2.349e+05 7.608e+05 3.24 52202 8958 3456 1431
#>
#>
#> Exact value: 53.232482, MLMC value: 53.237966
#>
#> ---- Computing Heston model ----
#>
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 2e+06 samples ***
#> **********************************************************
#>
#> l ave(Pf-Pc) ave(Pf) var(Pf-Pc) var(Pf) kurtosis check cost
#> ---------------------------------------------------------------------------------------
#> 0 1.0217e+01 1.0217e+01 1.6116e+02 1.6116e+02 0.0000e+00 0.0000e+00 1.0000e+00
#> 1 2.1361e-01 1.0424e+01 3.5554e+00 1.9063e+02 1.5022e+01 1.1127e-01 4.0000e+00
#> 2 3.2716e-02 1.0424e+01 3.7040e+00 1.9165e+02 7.4001e+00 5.1720e-01 1.6000e+01
#> 3 5.2579e-03 1.0442e+01 1.7502e+00 1.9157e+02 6.1162e+00 2.0107e-01 6.4000e+01
#> 4 1.3222e-03 1.0449e+01 5.1204e-01 1.9160e+02 5.5678e+00 9.7420e-02 2.5600e+02
#> 5 1.2331e-04 1.0477e+01 1.3359e-01 1.9208e+02 5.4375e+00 4.6277e-01 1.0240e+03
#>
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#>
#> alpha = 2.614583 (exponent for MLMC weak convergence)
#> beta = 1.232292 (exponent for MLMC variance)
#> gamma = 2.000000 (exponent for MLMC cost)
#>
#> *****************************
#> *** MLMC complexity tests ***
#> *****************************
#>
#> eps value mlmc_cost std_cost savings N_l
#> -----------------------------------------------------------
#> 0.0050 1.0456e+01 6.441e+07 6.539e+08 10.15 23522225 1747622 890878 306918
#> 0.0100 1.0453e+01 1.606e+07 1.635e+08 10.18 5872993 434922 222298 76339
#> 0.0200 1.0466e+01 1.956e+06 1.022e+07 5.23 1024914 76452 39061
#> 0.0500 1.0467e+01 3.128e+05 1.635e+06 5.23 163241 12489 6228
#> 0.1000 1.0485e+01 8.505e+04 4.088e+05 4.81 44380 3584 1646
#>
#>
#> Exact value unknown, MLMC value: 10.456461
# }
# The level sampler can be called directly to retrieve the relevant level sums:
opre_l(l = 7, N = 10, option = 1)
#> $sums
#> [1] 2.790908e-01 1.932997e-02 1.494244e-03 1.232423e-04 1.698023e+02
#> [6] 4.757903e+03
#>
#> $cost
#> [1] 163840
#>