Skip to contents

Financial options based on scalar geometric Brownian motion, similar to Mike Giles' MCQMC06 paper, Giles (2008), using a Milstein discretisation.

Usage

mcqmc06_l(l, N, option)

Arguments

l

the level to be simulated.

N

the number of samples to be computed.

option

the option type, between 1 and 5. The options are:

1 = European call;
2 = Asian call;
3 = lookback call;
4 = digital call;
5 = barrier call.

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 by mlmc.test() for convergence tests etc;

cost

is a scalar with the total cost of the paths simulated, computed as \(N \times 2^l\) for level \(l\).

Details

This function is based on GPL-2 C++ code by Mike Giles.

References

Giles, M. (2008) 'Improved Multilevel Monte Carlo Convergence using the Milstein Scheme', in A. Keller, S. Heinrich, and H. Niederreiter (eds) Monte Carlo and Quasi-Monte Carlo Methods 2006. Berlin, Heidelberg: Springer, pp. 343–358. Available at: doi:10.1007/978-3-540-74496-2_20 .

Author

Louis Aslett <louis.aslett@durham.ac.uk>

Mike Giles <Mike.Giles@maths.ox.ac.uk>

Examples

# \donttest{
# These are similar to the MLMC tests for the MCQMC06 paper
# using a Milstein discretisation with 2^l timesteps on level l
#
# The figures are slightly different due to:
# -- change in MSE split
# -- change in cost calculation
# -- different random number generation
# -- switch to S_0=100
#
# Note the following takes quite a while to run, for a toy example see after
# this block.

N0   <- 200 # initial samples on coarse levels
Lmin <- 2 # minimum refinement level
Lmax <- 10 # maximum refinement level

test.res <- list()
for(option in 1:5) {
  if(option == 1) {
    cat("\n ---- Computing European call ---- \n")
    N      <- 20000 # samples for convergence tests
    L      <- 8 # 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      <- 20000 # samples for convergence tests
    L      <- 8 # 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      <- 20000 # samples for convergence tests
    L      <- 10 # levels for convergence tests
    Eps    <- c(0.005, 0.01, 0.02, 0.05, 0.1)
  } else if(option == 4) {
    cat("\n ---- Computing digital call ---- \n")
    N      <- 200000 # samples for convergence tests
    L      <- 8 # levels for convergence tests
    Eps    <- c(0.01, 0.02, 0.05, 0.1, 0.2)
  } else if(option == 5) {
    cat("\n ---- Computing barrier call ---- \n")
    N      <- 200000 # samples for convergence tests
    L      <- 8 # levels for convergence tests
    Eps    <- c(0.005, 0.01, 0.02, 0.05, 0.1)
  }

  test.res[[option]] <- mlmc.test(mcqmc06_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
  B   <- 0.85*K

  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))
  d3  <- (2*log(B/K) + (r+0.5*sig^2)*T) / (sig*sqrt(T))
  d4  <- (2*log(B/K) + (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 <- K*(                             pnorm(d1) - exp(-r*T)*pnorm(d2) -
              ((K/B)^(1-1/k))*((B^2)/(K^2)*pnorm(d3) - exp(-r*T)*pnorm(d4)) )
  }

  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 = 20000 samples                            ***
#> **********************************************************
#> 
#>  l   ave(Pf-Pc)    ave(Pf)   var(Pf-Pc)    var(Pf)    kurtosis      check       cost
#> ---------------------------------------------------------------------------------------
#>  0   1.0030e+01  1.0030e+01  1.9725e+02  1.9725e+02  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   1.8716e-01  1.0359e+01  1.6531e-01  2.0988e+02  9.8531e+01  2.3102e-01  2.0000e+00 
#>  2   1.0142e-01  1.0191e+01  4.1839e-02  2.0683e+02  2.8282e+01  4.3754e-01  4.0000e+00 
#>  3   5.5153e-02  1.0558e+01  1.2325e-02  2.1670e+02  2.1426e+01  5.0386e-01  8.0000e+00 
#>  4   2.7904e-02  1.0468e+01  3.2321e-03  2.1466e+02  1.7647e+01  1.8893e-01  1.6000e+01 
#>  5   1.3913e-02  1.0420e+01  8.2640e-04  2.1465e+02  1.2310e+01  9.9685e-02  3.2000e+01 
#>  6   7.2131e-03  1.0479e+01  2.1421e-04  2.1745e+02  1.1577e+01  8.2241e-02  6.4000e+01 
#>  7   3.5650e-03  1.0475e+01  5.2975e-05  2.1736e+02  1.0232e+01  1.0760e-02  1.2800e+02 
#>  8   1.7857e-03  1.0545e+01  1.3436e-05  2.1571e+02  1.0093e+01  1.0816e-01  2.5600e+02 
#> 
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#> 
#>  alpha = 0.963583  (exponent for MLMC weak convergence)
#>  beta  = 1.937392  (exponent for MLMC variance) 
#>  gamma = 1.000000  (exponent for MLMC cost) 
#> 
#> ***************************** 
#> *** MLMC complexity tests *** 
#> ***************************** 
#> 
#>   eps      value    mlmc_cost   std_cost  savings     N_l 
#> ----------------------------------------------------------- 
#> 0.0050  1.0458e+01  1.361e+07  2.945e+09   216.36  11917020    231958     98151     33333     12301      4375      1552       615       223
#> 0.0100  1.0439e+01  3.356e+06  3.710e+08   110.52   2953179     65020     21963      7800      2913      1068       386       136
#> 0.0200  1.0470e+01  8.371e+05  4.639e+07    55.41    740921     14276      5398      2185       776       293       106
#> 0.0500  1.0461e+01  1.312e+05  3.663e+06    27.93    117176      2060       829       365       132        48
#> 0.1000  1.0304e+01  3.137e+04  4.579e+05    14.60     28620       543       200        64        22
#> 
#> 
#>  Exact value: 10.450584, MLMC value: 10.458105 

#> 
#>  ---- Computing Asian call ---- 
#> 
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 20000 samples                            ***
#> **********************************************************
#> 
#>  l   ave(Pf-Pc)    ave(Pf)   var(Pf-Pc)    var(Pf)    kurtosis      check       cost
#> ---------------------------------------------------------------------------------------
#>  0   5.6185e+00  5.6185e+00  6.0313e+01  6.0313e+01  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   4.1755e-02  5.6931e+00  2.6371e-01  6.2423e+01  2.3578e+01  9.5912e-02  2.0000e+00 
#>  2   3.9962e-02  5.7058e+00  3.7704e-02  6.1951e+01  1.2360e+01  8.0573e-02  4.0000e+00 
#>  3   2.7370e-02  5.7290e+00  6.0579e-03  6.2682e+01  8.1099e+00  1.2570e-02  8.0000e+00 
#>  4   1.5138e-02  5.7909e+00  1.2289e-03  6.4331e+01  7.6054e+00  1.3822e-01  1.6000e+01 
#>  5   7.5845e-03  5.7123e+00  2.6881e-04  6.3121e+01  7.4456e+00  2.5437e-01  3.2000e+01 
#>  6   3.8863e-03  5.6738e+00  6.2498e-05  6.1495e+01  7.9930e+00  1.2635e-01  6.4000e+01 
#>  7   1.9756e-03  5.7571e+00  1.5521e-05  6.2941e+01  7.8415e+00  2.4282e-01  1.2800e+02 
#>  8   1.0065e-03  5.8278e+00  3.8637e-06  6.4531e+01  7.4338e+00  2.0594e-01  2.5600e+02 
#> 
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#> 
#>  alpha = 0.818556  (exponent for MLMC weak convergence)
#>  beta  = 2.269413  (exponent for MLMC variance) 
#>  gamma = 1.000000  (exponent for MLMC cost) 
#> 
#> ***************************** 
#> *** MLMC complexity tests *** 
#> ***************************** 
#> 
#>   eps      value    mlmc_cost   std_cost  savings     N_l 
#> ----------------------------------------------------------- 
#> 0.0050  5.7609e+00  4.738e+06  8.811e+08   185.94   3878099    176768     48852     15162      4375      1512       497       178        67
#> 0.0100  5.7537e+00  1.407e+06  1.074e+08    76.37   1189144     44761     13058      3745      1110       392       142        50
#> 0.0200  5.7585e+00  2.909e+05  1.312e+07    45.09    239760     10909      2985       928       289       104        32
#> 0.0500  5.7167e+00  4.541e+04  1.077e+06    23.72     37708      1729       451       149        48        15
#> 0.1000  5.6693e+00  1.250e+04  1.372e+05    10.98     10250       429       200        38        18
#> 
#> 
#>  Exact value unknown, MLMC value: 5.760949 

#> 
#>  ---- Computing lookback call ---- 
#> 
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 20000 samples                            ***
#> **********************************************************
#> 
#>  l   ave(Pf-Pc)    ave(Pf)   var(Pf-Pc)    var(Pf)    kurtosis      check       cost
#> ---------------------------------------------------------------------------------------
#>  0   1.7603e+01  1.7603e+01  1.8757e+02  1.8757e+02  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   -1.1974e-01  1.7458e+01  1.4071e+00  1.9666e+02  9.2816e+00  4.0921e-02  2.0000e+00 
#>  2   -1.3427e-01  1.7475e+01  5.0942e-01  2.0891e+02  9.1129e+00  2.4391e-01  4.0000e+00 
#>  3   -8.8887e-02  1.7226e+01  1.4282e-01  2.0632e+02  9.4423e+00  2.5918e-01  8.0000e+00 
#>  4   -5.4996e-02  1.7188e+01  4.0886e-02  2.1052e+02  8.3295e+00  2.7305e-02  1.6000e+01 
#>  5   -2.6679e-02  1.7198e+01  1.0245e-02  2.1394e+02  8.6646e+00  5.9360e-02  3.2000e+01 
#>  6   -1.4201e-02  1.7086e+01  2.6724e-03  2.0766e+02  8.6317e+00  1.5823e-01  6.4000e+01 
#>  7   -7.2594e-03  1.7233e+01  6.7415e-04  2.1055e+02  7.3269e+00  2.5092e-01  1.2800e+02 
#>  8   -3.5000e-03  1.7275e+01  1.6549e-04  2.1712e+02  7.9473e+00  7.3983e-02  2.5600e+02 
#>  9   -1.7809e-03  1.7173e+01  4.1676e-05  2.1442e+02  7.3364e+00  1.6080e-01  5.1200e+02 
#> 10   -8.6176e-04  1.7440e+01  1.0424e-05  2.1902e+02  8.6798e+00  4.2827e-01  1.0240e+03 
#> 
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#> 
#>  alpha = 0.852889  (exponent for MLMC weak convergence)
#>  beta  = 1.920578  (exponent for MLMC variance) 
#>  gamma = 1.000000  (exponent for MLMC cost) 
#> 
#> ***************************** 
#> *** MLMC complexity tests *** 
#> ***************************** 
#> 
#>   eps      value    mlmc_cost   std_cost  savings     N_l 
#> ----------------------------------------------------------- 
#> 0.0050  1.7220e+01  2.197e+07  1.196e+10   544.53  14695671    908426    378089    146440     54138     19500      6933      2469       917       332       113
#> 0.0100  1.7227e+01  5.350e+06  7.411e+08   138.53   3626992    222962     92265     36156     13314      4941      1741       615       223
#> 0.0200  1.7201e+01  1.334e+06  1.853e+08   138.92    902716     55846     23242      9121      3370      1208       430       150        55
#> 0.0500  1.7265e+01  2.030e+05  7.088e+06    34.92    141854      8734      3548      1379       508       186        68
#> 0.1000  1.7118e+01  5.179e+04  1.772e+06    34.21     35378      2295       934       393       137        50        18
#> 
#> 
#>  Exact value: 17.216802, MLMC value: 17.220350 

#> 
#>  ---- Computing digital call ---- 
#> 
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 2e+05 samples                            ***
#> **********************************************************
#> 
#>  l   ave(Pf-Pc)    ave(Pf)   var(Pf-Pc)    var(Pf)    kurtosis      check       cost
#> ---------------------------------------------------------------------------------------
#>  0   5.6951e+01  5.6951e+01  1.0000e-10  1.0000e-10  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   -2.7021e+00  5.4263e+01  2.0431e-01  7.2354e+02  1.1150e+01  7.9904e-02  2.0000e+00 
#>  2   -7.1604e-01  5.3580e+01  1.9385e+00  1.1897e+03  1.9612e+01  7.8338e-02  4.0000e+00 
#>  3   -2.0194e-01  5.3346e+01  1.2403e+00  1.5085e+03  2.2141e+01  6.4013e-02  8.0000e+00 
#>  4   -5.9328e-02  5.3352e+01  5.4685e-01  1.7222e+03  2.7503e+01  1.2010e-01  1.6000e+01 
#>  5   -2.2149e-02  5.3216e+01  2.1220e-01  1.8724e+03  4.3452e+01  1.9886e-01  3.2000e+01 
#>  6   -7.9524e-03  5.3246e+01  7.8848e-02  1.9789e+03  5.6893e+01  6.2962e-02  6.4000e+01 
#>  7   -3.6181e-03  5.3389e+01  2.7991e-02  2.0497e+03  8.0117e+01  2.4439e-01  1.2800e+02 
#>  8   -1.2441e-03  5.3354e+01  1.0449e-02  2.1024e+03  1.1769e+02  5.5995e-02  2.5600e+02 
#> 
#>  WARNING: kurtosis on finest level = 117.692596 
#>  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 = 1.561395  (exponent for MLMC weak convergence)
#>  beta  = 0.879603  (exponent for MLMC variance) 
#>  gamma = 1.000000  (exponent for MLMC cost) 
#> 
#> ***************************** 
#> *** MLMC complexity tests *** 
#> ***************************** 
#> 
#>   eps      value    mlmc_cost   std_cost  savings     N_l 
#> ----------------------------------------------------------- 
#> 0.0100  5.3242e+01  3.755e+06  3.498e+09   931.64       200     71109    155815     88148     41078     17950      8299      4072
#> 0.0200  5.3237e+01  7.650e+05  4.222e+08   551.88       200     16210     34921     20467      9378      4267      2224
#> 0.0500  5.3256e+01  1.001e+05  3.195e+07   319.11       200      2404      4796      2991      1591       830
#> 0.1000  5.3214e+01  1.210e+04  3.674e+06   303.70       200       381       842       475       248
#> 0.2000  5.3294e+01  4.020e+03  9.185e+05   228.49       200       200       283       140        73
#> 
#> 
#>  Exact value: 53.232482, MLMC value: 53.241652 

#> 
#>  ---- Computing barrier call ---- 
#> 
#> **********************************************************
#> *** Convergence tests, kurtosis, telescoping sum check ***
#> *** using N = 2e+05 samples                            ***
#> **********************************************************
#> 
#>  l   ave(Pf-Pc)    ave(Pf)   var(Pf-Pc)    var(Pf)    kurtosis      check       cost
#> ---------------------------------------------------------------------------------------
#>  0   9.4564e+00  9.4564e+00  1.8871e+02  1.8871e+02  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   1.6056e-01  9.6193e+00  1.7069e-01  1.9914e+02  6.1603e+01  1.2323e-02  2.0000e+00 
#>  2   1.4474e-01  9.6700e+00  1.5745e-01  2.0464e+02  1.0612e+02  4.8690e-01  4.0000e+00 
#>  3   9.8315e-02  9.8418e+00  1.4427e-01  2.1162e+02  3.9947e+02  3.7507e-01  8.0000e+00 
#>  4   4.6888e-02  9.9143e+00  5.1685e-02  2.1567e+02  1.5447e+03  1.2963e-01  1.6000e+01 
#>  5   2.0359e-02  9.9093e+00  1.0326e-02  2.1578e+02  1.2857e+03  1.2834e-01  3.2000e+01 
#>  6   1.0032e-02  9.9355e+00  4.2701e-03  2.1714e+02  3.9267e+03  8.1491e-02  6.4000e+01 
#>  7   4.8781e-03  9.9329e+00  1.1130e-03  2.1622e+02  1.7346e+03  3.7701e-02  1.2800e+02 
#>  8   2.3827e-03  9.9133e+00  4.1529e-04  2.1690e+02  6.9372e+03  1.1119e-01  2.5600e+02 
#> 
#>  WARNING: kurtosis on finest level = 6937.174649 
#>  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 = 0.929256  (exponent for MLMC weak convergence)
#>  beta  = 1.357869  (exponent for MLMC variance) 
#>  gamma = 1.000000  (exponent for MLMC cost) 
#> 
#> ***************************** 
#> *** MLMC complexity tests *** 
#> ***************************** 
#> 
#>   eps      value    mlmc_cost   std_cost  savings     N_l 
#> ----------------------------------------------------------- 
#> 0.0050  9.9433e+00  2.155e+07  5.923e+09   274.79  14584932    310729    219105    148864     56194     21897     10346      7173      2550       873
#> 0.0100  9.9355e+00  4.662e+06  7.403e+08   158.79   3394165     72037     49865     32362     13511      5756      2045       645       203
#> 0.0200  9.9761e+00  1.264e+06  9.225e+07    72.96    883634     18369     12864      8275      3246      2341       951       302
#> 0.0500  9.8703e+00  1.638e+05  7.412e+06    45.25    127079      2734      2077       943       407       169        54
#> 0.1000  9.7337e+00  3.815e+04  9.207e+05    24.13     30393       711       400       260        98        34
#> 
#> 
#>  Exact value: 9.949270, MLMC value: 9.943268 

# }

# The level sampler can be called directly to retrieve the relevant level sums:
mcqmc06_l(l = 7, N = 10, option = 1)
#> $sums
#> [1] 2.648764e-02 2.889784e-04 3.607043e-06 5.105926e-08 1.032765e+02
#> [6] 2.338980e+03
#> 
#> $cost
#> [1] 1280
#>