Speed

A Payoff on the Whole Path

Simulation earns its place where the payoff depends on the whole price path. An option on the average price has no simple formula in this book; the method is unchanged: sample paths, average the discounted payoffs, and read the standard error.

The question

Every payoff so far depended on the price at expiry alone, and for those the model has a closed form. A call on the average price pays max(A - K, 0), where A is the average of the prices on a set of dates up to expiry. The average depends on the path the price took, not only on where it ended, and this book has no simple formula for it. How is it priced?

The same way: draw price paths from the model, compute the payoff of each, average and discount. This lesson samples whole paths with a seed per path, prices an average-price call from 500 of them, and sets the engine's own estimate and its standard error beside it. The paths are model paths, not price histories.

Work it by hand

Take one path of a price, made up for this hand example: 100 today, then 108, 96 and 112 at three equally spaced dates. With strike 100 the average of the three later prices is (108 + 96 + 112) / 3 = 105.33, and the average-price call pays 5.33. The plain call on the last price alone pays 112 - 100 = 12.

The average smooths the path: one high late price counts once among three. On a path 100, 120, 130, 97 the plain call pays 0, while the average of the three later prices is 115.67 and the average-price call pays 15.67. The value of the option is the average of such payoffs over many paths, discounted once, which is what the program does.

Run it

The loop of lines 12 to 16 draws a path with model.sample_path for each seed from 1 to count (line 13), adds the payoff of the average-price call (line 14) and returns the first four paths, rounded to cents, for the picture (line 15).

Line 17 asks the engine for 20,000 paths of the same option with pricing.monte_carlo_plain and the seed 42. Line 18 takes the plain call's closed form. Lines 19 to 23 return the time points, the loop's own estimate, the engine's estimate and standard error, and the closed form. Line 24 returns the closed form in whole cents.

Four price paths of 13 points from 100 at time 0 to time 1: path 1 rises to 132.02 and ends at 97.51, path 2 falls to 84.72 and ends at 91.33, path 3 ends at 96.96, and path 4 climbs to 152.63 and ends at 137.78.
fn cents(p: FloatList) -> FloatList {
  let r = float_list();
  for (j in range(0, p.len())) { r.add(lmf.round(p.at(j), 2)); }
  return r;
}
let m = model.black_scholes(spot, rate, 0.0, vol);
let asian = instrument.asian_call(strike, 1.0, "arithmetic", steps);
let plain = instrument.european_call(strike, 1.0);
let x = float_list();
for (j in range(0, steps + 1)) { x.add(float(j) / float(steps)); }
let total = 0.0;
for (k in range(1, count + 1)) {
  let path = model.sample_path(m, 1.0, steps, k);
  total = total + asian.path_payoff(path);
  if (k <= 4) { lmcode_return_put("path" + str(k), cents(path)); }
}
let run = pricing.price(asian, m, pricing.monte_carlo_plain(20000, 42));
let exact = pricing.price(plain, m, pricing.analytic()).price();
lmcode_return_put("time", x);
lmcode_return_put("own", lmf.round(total / float(count) / lmf.exp(rate), 4));
lmcode_return_put("engine", lmf.round(run.price(), 4));
lmcode_return_put("error", lmf.round(run.stderr(), 4));
lmcode_return_put("plain", lmf.round(exact, 4));
let answer = int(math_round(lmf.round(exact, 2) * 100.0));
{
  "answer": 1045,
  "path1": [
    100,
    99.04,
    116.5,
    120.8,
    132.02,
    106.99,
    100.45,
    97.73,
    117.2,
    110.58,
    106.35,
    98.75,
    97.51
  ],
  "path2": [
    100,
    99.32,
    94.55,
    84.72,
    92.55,
    93.45,
    102.89,
    102.18,
    102.21,
    101.29,
    98.84,
    96.61,
    91.33
  ],
  "path3": [
    100,
    100.99,
    93,
    96.23,
    102.18,
    99.23,
    92.98,
    93.36,
    94.55,
    101.83,
    101.16,
    109.07,
    96.96
  ],
  "path4": [
    100,
    111.48,
    120.37,
    121.5,
    115.34,
    129.2,
    137.7,
    142.65,
    145.31,
    150.09,
    152.63,
    146.23,
    137.78
  ],
  "time": [
    0,
    0.08333333333333333,
    0.16666666666666666,
    0.25,
    0.3333333333333333,
    0.4166666666666667,
    0.5,
    0.5833333333333334,
    0.6666666666666666,
    0.75,
    0.8333333333333334,
    0.9166666666666666,
    1
  ],
  "own": 6.1018,
  "engine": 6.1526,
  "error": 0.0602,
  "plain": 10.4506
}

With 12 steps and the seeds 1 to 500 the loop's estimate of the average-price call is 6.10, the engine's is 6.15 with a standard error of 0.06, and the plain call is worth 10.45: the average-price call is worth less. The picture shows four sample paths. These come from the seeds; other seeds give other numbers.

You can change steps, count and the option inputs.

count should be at least 4, or the picture lacks paths. steps must be from 1 to 200: 201 or more stop line 17 with "monte carlo: paths times fixings must be at most 4000000, got 20000 x 201 = 4020000" (the engine prices 20,000 paths), and from 366 up with "Asian fixings fall on the same day: use fewer fixings or a longer maturity".

model.sample_path itself accepts 1 to 1000 steps: 1001 stops line 13 with "model.sample_path: steps must be 1..1000, got 1001". A steps of 0 or less, or above 10000, stops line 7 with "fixings must be 1..10000". A strike of 0 or less stops line 7 with "option strike must be positive", and a spot or a volatility of 0 or less stops line 6 with "model.black_scholes: spot must be positive" or "model.black_scholes: volatility must be positive".

A count of 0 stops line 20 with "LmfApi.round argument 1 must be finite", and a negative one draws no path and returns 0 as the loop's estimate. Inputs far outside any sensible range stop the run as well: a rate of 800 stops line 14 with "Option.path_payoff: prices must be positive, got inf at index 11". The picture shows at most 64 points of each path; keep count at most about 500 and steps at most about 12 for a quick run.

Your turn

The list path holds a price path, today's price first. The program below is meant to return the payoff of the arithmetic average-price call with strike strike, in whole cents, where the average runs over the prices after the first, and the payoff is not discounted. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on four others.

The strike 52, a path of five prices from 50 to 58, and the payoff in whole cents that the shown program returns.
let n = path.len() - 1;
let option = instrument.asian_call(strike, 1.0, "geometric", n);
let value = lmf.round(option.path_payoff(path), 2);
let answer = int(math_round(value * 100.0));
{
  "answer": 164
}

The list path holds one price path, today's price first and then the later prices. Return the payoff of the arithmetic average-price call with the given strike, in whole cents, not discounted: max(A - strike, 0), where A is the average of the prices after the first. Check runs each candidate on the data shown and on four others.

Read the result carefully

There is no closed form here to check the estimate against, so its standard error is the only measure of the sampling error. The estimate also inherits the model's assumptions: a constant volatility, equally spaced model paths and no costs. More paths shrink the sampling error and leave those untouched.

In the exercise the path is given, so the answer is an exact calculation on one path; the value of the option would be the discounted average of such payoffs over many paths.

A path of a single point has no fixing: the program then stops with "fixings must be 1..10000".

Money answers are whole cents because the engine works in binary floating point, where numbers such as 1.1 or 105.05 have no exact form and a raw result can end in a stray digit; the page rounds with lmf.round before it shows or compares. It is a description of an arithmetic model and not investment advice.

Payoffs that depend on the whole path, a barrier and an average, have their own book: Barrier and Asian Options Step by Step.

Recap

  • A payoff that depends on the whole path can be priced by sampling paths, averaging the payoffs and discounting.
  • The average-price call pays max(A - K, 0) with A the average of the prices after today's.
  • The same standard error measures the sampling error; here no closed form is at hand to check it.
  • The average-price call is worth less than the plain call in the demo, because the average smooths the path.