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.0029e+01  1.0029e+01  1.9722e+02  1.9722e+02  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   1.8394e-01  1.0290e+01  1.4600e-01  2.0587e+02  3.9810e+01  1.2720e-01  2.0000e+00 
#>  2   1.0333e-01  1.0388e+01  4.2175e-02  2.1234e+02  3.3379e+01  8.3887e-03  4.0000e+00 
#>  3   5.4322e-02  1.0369e+01  1.1838e-02  2.1705e+02  1.6591e+01  1.1764e-01  8.0000e+00 
#>  4   2.8126e-02  1.0552e+01  3.2235e-03  2.1932e+02  1.3227e+01  2.4578e-01  1.6000e+01 
#>  5   1.3857e-02  1.0318e+01  8.3669e-04  2.1392e+02  1.3113e+01  3.9635e-01  3.2000e+01 
#>  6   7.1684e-03  1.0487e+01  2.0915e-04  2.1799e+02  1.1029e+01  2.5931e-01  6.4000e+01 
#>  7   3.5655e-03  1.0418e+01  5.1754e-05  2.1059e+02  9.7300e+00  1.1593e-01  1.2800e+02 
#>  8   1.7807e-03  1.0446e+01  1.3881e-05  2.2270e+02  1.3242e+01  4.0847e-02  2.5600e+02 
#> 
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#> 
#>  alpha = 0.963172  (exponent for MLMC weak convergence)
#>  beta  = 1.920125  (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.0456e+01  1.357e+07  3.041e+09   224.13  11906524    232615     91191     33305     12323      4397      1541       574       209
#> 0.0100  1.0448e+01  3.358e+06  3.594e+08   107.02   2957299     58040     24187      8085      2986      1072       388       130
#> 0.0200  1.0474e+01  8.373e+05  4.650e+07    55.54    739789     15333      5622      1982       806       291        98
#> 0.0500  1.0455e+01  1.324e+05  3.651e+06    27.57    117749      2356       823       375       135        47
#> 0.1000  1.0323e+01  3.216e+04  4.679e+05    14.55     28570       569       200       104        51
#> 
#> 
#>  Exact value: 10.450584, MLMC value: 10.456468 

#> 
#>  ---- 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.5951e+00  5.5951e+00  6.0102e+01  6.0102e+01  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   4.1848e-02  5.6599e+00  2.5574e-01  6.1727e+01  1.6183e+01  6.7128e-02  2.0000e+00 
#>  2   4.1015e-02  5.6638e+00  3.8719e-02  6.1679e+01  1.3926e+01  1.0993e-01  4.0000e+00 
#>  3   2.7105e-02  5.8340e+00  6.1034e-03  6.3818e+01  8.0283e+00  4.2362e-01  8.0000e+00 
#>  4   1.5105e-02  5.7268e+00  1.2618e-03  6.3991e+01  8.9021e+00  3.5953e-01  1.6000e+01 
#>  5   7.5520e-03  5.7032e+00  2.7444e-04  6.3187e+01  8.1746e+00  9.2026e-02  3.2000e+01 
#>  6   3.9493e-03  5.7242e+00  6.3849e-05  6.2996e+01  7.4206e+00  5.0343e-02  6.4000e+01 
#>  7   1.9923e-03  5.7760e+00  1.5791e-05  6.3790e+01  8.4057e+00  1.4766e-01  1.2800e+02 
#>  8   9.9651e-04  5.7188e+00  3.7720e-06  6.3177e+01  7.4076e+00  1.7234e-01  2.5600e+02 
#> 
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#> 
#>  alpha = 0.820236  (exponent for MLMC weak convergence)
#>  beta  = 2.268800  (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.7605e+00  4.725e+06  8.626e+08   182.56   3873079    175297     48809     15168      4535      1444       485       166        53
#> 0.0100  5.7535e+00  1.182e+06  1.089e+08    92.10    968052     44224     12467      3893      1173       374       132        42
#> 0.0200  5.7370e+00  2.894e+05  1.344e+07    46.44    239448     10974      2833       894       284        95        30
#> 0.0500  5.7458e+00  4.528e+04  5.461e+05    12.06     37958      1862       436       140        46
#> 0.1000  5.6778e+00  1.039e+04  3.290e+04     3.17      8849       371       200
#> 
#> 
#>  Exact value unknown, MLMC value: 5.760501 

#> 
#>  ---- 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.7511e+01  1.7511e+01  1.8272e+02  1.8272e+02  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   -1.1451e-01  1.7641e+01  1.4254e+00  1.9415e+02  1.0742e+01  4.0186e-01  2.0000e+00 
#>  2   -1.3721e-01  1.7368e+01  4.9198e-01  2.0461e+02  8.3115e+00  2.2081e-01  4.0000e+00 
#>  3   -9.4454e-02  1.7255e+01  1.4952e-01  2.1249e+02  8.0617e+00  3.0306e-02  8.0000e+00 
#>  4   -5.4218e-02  1.7330e+01  4.0505e-02  2.1245e+02  7.6582e+00  2.0807e-01  1.6000e+01 
#>  5   -2.8215e-02  1.7190e+01  1.0298e-02  2.1322e+02  7.4335e+00  1.8081e-01  3.2000e+01 
#>  6   -1.4180e-02  1.7217e+01  2.6559e-03  2.1334e+02  9.3109e+00  6.6450e-02  6.4000e+01 
#>  7   -7.2142e-03  1.7281e+01  6.7944e-04  2.1261e+02  7.8428e+00  1.1579e-01  1.2800e+02 
#>  8   -3.5886e-03  1.7277e+01  1.6721e-04  2.1483e+02  7.2920e+00  1.4140e-03  2.5600e+02 
#>  9   -1.7421e-03  1.7406e+01  4.1219e-05  2.1655e+02  7.2133e+00  2.1006e-01  5.1200e+02 
#> 10   -8.5668e-04  1.7203e+01  1.0125e-05  2.1479e+02  7.5526e+00  3.2429e-01  1.0240e+03 
#> 
#> ******************************************************
#> *** Linear regression estimates of MLMC parameters ***
#> ******************************************************
#> 
#>  alpha = 0.854377  (exponent for MLMC weak convergence)
#>  beta  = 1.923630  (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.198e+07  1.173e+10   533.68  14705013    903557    378904    146464     53597     19602      6853      2548       928       335       119
#> 0.0100  1.7220e+01  5.439e+06  1.478e+09   271.80   3656467    225494     93830     36431     13514      4838      1751       625       229        84
#> 0.0200  1.7217e+01  1.333e+06  1.833e+08   137.50    903171     55947     23402      9207      3330      1206       429       135        56
#> 0.0500  1.7195e+01  2.276e+05  1.451e+07    63.77    158622      9132      3715      1505       513       218        79        28
#> 0.1000  1.7285e+01  4.837e+04  9.097e+05    18.81     34322      2144       884       354       126        43
#> 
#> 
#>  Exact value: 17.216802, MLMC value: 17.220294 

#> 
#>  ---- 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.7040e+00  5.4204e+01  2.0283e-01  7.2524e+02  1.1215e+01  2.3129e-01  2.0000e+00 
#>  2   -7.1971e-01  5.3474e+01  1.9122e+00  1.1903e+03  1.8316e+01  2.4219e-02  4.0000e+00 
#>  3   -2.0226e-01  5.3362e+01  1.2522e+00  1.5093e+03  2.2352e+01  1.8000e-01  8.0000e+00 
#>  4   -6.1953e-02  5.3186e+01  5.4529e-01  1.7271e+03  3.2836e+01  2.0907e-01  1.6000e+01 
#>  5   -2.1556e-02  5.3342e+01  2.1123e-01  1.8701e+03  4.3469e+01  3.1090e-01  3.2000e+01 
#>  6   -7.6433e-03  5.3245e+01  7.9410e-02  1.9777e+03  5.9358e+01  1.5181e-01  6.4000e+01 
#>  7   -3.5706e-03  5.3145e+01  2.8310e-02  2.0528e+03  8.5312e+01  1.5978e-01  1.2800e+02 
#>  8   -2.1199e-03  5.3293e+01  1.0033e-02  2.1033e+03  1.3585e+02  2.4542e-01  2.5600e+02 
#> 
#>  WARNING: kurtosis on finest level = 135.851963 
#>  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.502312  (exponent for MLMC weak convergence)
#>  beta  = 0.881623  (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.3252e+01  2.929e+06  1.688e+09   576.20       200     62778    136754     79398     36565     16168      8103
#> 0.0200  5.3233e+01  7.604e+05  4.219e+08   554.87       200     15902     34931     20474      9468      4287      2128
#> 0.0500  5.3287e+01  8.405e+04  3.192e+07   379.75       200      2165      4461      2581      1256       654
#> 0.1000  5.3398e+01  1.850e+04  3.685e+06   199.19       200       477      1192       770       401
#> 0.2000  5.3154e+01  3.136e+03  9.211e+05   293.73       200       200       204       105        55
#> 
#> 
#>  Exact value: 53.232482, MLMC value: 53.251801 

#> 
#>  ---- 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.4474e+00  9.4474e+00  1.8929e+02  1.8929e+02  0.0000e+00  0.0000e+00  1.0000e+00 
#>  1   1.5951e-01  9.6066e+00  1.7046e-01  1.9977e+02  6.4497e+01  1.7977e-03  2.0000e+00 
#>  2   1.4617e-01  9.7725e+00  1.5850e-01  2.0847e+02  9.9998e+01  1.0141e-01  4.0000e+00 
#>  3   9.7979e-02  9.8558e+00  1.5455e-01  2.1263e+02  5.7430e+02  7.3983e-02  8.0000e+00 
#>  4   4.6242e-02  9.9139e+00  4.6293e-02  2.1629e+02  1.1486e+03  5.9766e-02  1.6000e+01 
#>  5   2.0943e-02  9.8764e+00  1.2250e-02  2.1494e+02  1.2541e+03  2.9562e-01  3.2000e+01 
#>  6   9.8981e-03  9.9351e+00  3.0235e-03  2.1906e+02  1.1802e+03  2.4669e-01  6.4000e+01 
#>  7   4.9817e-03  9.9004e+00  1.4311e-03  2.1603e+02  5.8747e+03  2.0031e-01  1.2800e+02 
#>  8   2.3914e-03  1.0021e+01  5.2788e-04  2.1924e+02  2.1485e+04  5.9808e-01  2.5600e+02 
#> 
#>  WARNING: kurtosis on finest level = 21484.500811 
#>  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.926866  (exponent for MLMC weak convergence)
#>  beta  = 1.324364  (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.9474e+00  2.058e+07  5.987e+09   290.96  14279726    303808    210948    147438     67635     25971      9121      3809      1625       518
#> 0.0100  9.9457e+00  4.929e+06  7.484e+08   151.83   3502625     74757     52075     36492     14831      5822      2249       998       318
#> 0.0200  9.9472e+00  1.090e+06  9.217e+07    84.57    818077     15653     12652      7844      3382      1089       348       124
#> 0.0500  9.9445e+00  1.856e+05  7.477e+06    40.29    135789      3080      2359      1480       640       205        87
#> 0.1000  9.8066e+00  3.432e+04  4.614e+05    13.45     29190       628       330       171        74
#> 
#> 
#>  Exact value: 9.949270, MLMC value: 9.947443 

# }

# The level sampler can be called directly to retrieve the relevant level sums:
mcqmc06_l(l = 7, N = 10, option = 1)
#> $sums
#> [1] 5.965277e-02 1.405983e-03 4.231701e-05 1.389170e-06 1.190440e+02
#> [6] 5.613734e+03
#> 
#> $cost
#> [1] 1280
#>