Advanced Methods, Part 1: Least-Squares Monte Carlo#
Monte Carlo moves forward in time, and early exercise is decided backwards: to know whether to exercise now, the holder needs the value of waiting, which depends on what happens later. The least-squares Monte Carlo method of Longstaff and Schwartz solves this by estimating the value of waiting from the simulated paths themselves, with a regression. It is the standard way to price American and Bermudan options in models with several factors, where a tree or a grid is too large. This is the first of two pages on more advanced methods.
The idea#
At an exercise date, each path has a stock price \(S\) and a payoff from exercising now, \(g(S)\). What it lacks is the value of continuing, \(C(S) = E[\text{discounted future cash flow} \mid S]\). This is a conditional expectation, and a regression estimates it: across all the paths, fit the later cash flow, discounted to now, as a function of the current price. The fit is a polynomial,
with the coefficients \(b_k\) found by least squares. The path exercises if \(g(S) > C(S)\).
The algorithm#
Simulate paths of the underlying on the exercise dates.
At the last date, the cash flow of each path is the payoff.
Go backwards. At each earlier date, discount the cash flows one period. Take the paths that are in the money, since only they have a decision to make, and regress their discounted cash flows on a polynomial of the stock.
On each of those paths, exercise if the payoff is above the fitted continuation value, and in that case replace the path’s cash flow by the payoff.
At the first date, discount once more and average.
Only the decision comes from the regression. The cash flow that is recorded is the actual one on the path, and not the fitted value. This keeps the estimate from being biased by the regression error in the way that using the fitted value would be.
Bias#
The method gives an estimate that is on average below the true price, since the exercise rule from a regression is not the best one, and any rule that is not the best is worth less. It has the opposite risk if the same paths are used to find the rule and to value it. The rule is then fitted to those paths’ own future, and it exploits information that a real holder would not have, which biases the price up. The remedy is to fit the rule on one set of paths and to value it on an independent set. The price from the second set is a statistical estimate of the value of a real strategy, and so is a genuine lower bound, up to the sampling error.
Choices that matter#
The basis. A polynomial of degree 2 to 4 in the price is common. Too low a degree misses the shape of the continuation value, and too high a degree overfits. For several factors the basis includes products of the factors. The choice of the degree and the basis is the subject of Regression and Fitting, Part 2: Polynomial Regression, which tests a continuation-value regression against the exact value.
The number of paths. The regression needs enough paths that its coefficients are stable.
The number of exercise dates. A finer grid of dates is closer to the American option and costs more.
Worked example#
The example prices a put with 50 exercise dates, the 50-date Bermudan on a tree being the reference, with the polynomial degree from 1 to 4 and 5,000 to 500,000 paths. For each, it fits the rule on one set of paths, and values it on the same paths and on a fresh set. Both use the European put as a control variate. It then varies the number of dates.
Python code
"""Least-squares Monte Carlo (Longstaff-Schwartz) for a Bermudan and American put, with the in-sample bias."""
import numpy as np
from common import K, R, S0, SIGMA, T, bs_price
from trinomial_example import crr_bermudan_put
DISC_FULL = np.exp(-R * T)
def simulate(n, steps, rng):
"""Stock at the exercise dates t_1 ... t_steps, from exact lognormal steps."""
dt = T / steps
z = rng.standard_normal((n, steps))
return S0 * np.exp(np.cumsum((R - 0.5 * SIGMA**2) * dt + SIGMA * np.sqrt(dt) * z, axis=1))
def fit_policy(paths, degree):
"""Backward induction: at each date regress the later discounted cash flow on a polynomial in S/K, in-the-money paths only."""
n, steps = paths.shape
disc = np.exp(-R * T / steps)
cash = np.maximum(K - paths[:, -1], 0.0)
coefficients = [None] * steps
for i in range(steps - 2, -1, -1):
cash = cash * disc
s = paths[:, i]
intrinsic = np.maximum(K - s, 0.0)
itm = intrinsic > 0
coef = np.polynomial.polynomial.polyfit(s[itm] / K, cash[itm], degree)
coefficients[i] = coef
exercise = itm & (intrinsic > np.polynomial.polynomial.polyval(s / K, coef))
cash = np.where(exercise, intrinsic, cash)
return coefficients, disc * cash
def apply_policy(paths, coefficients):
"""Value of following the fitted exercise rule on a set of paths: exercise at the first date the rule says so."""
n, steps = paths.shape
dt = T / steps
value = np.zeros(n)
alive = np.ones(n, dtype=bool)
for i in range(steps - 1):
s = paths[:, i]
intrinsic = np.maximum(K - s, 0.0)
go = alive & (intrinsic > 0) & (intrinsic > np.polynomial.polynomial.polyval(s / K, coefficients[i]))
value[go] = intrinsic[go] * np.exp(-R * (i + 1) * dt)
alive &= ~go
value[alive] = np.maximum(K - paths[alive, -1], 0.0) * DISC_FULL
return value
def with_control(value, paths):
"""Estimate and standard error after removing noise shared with the European put on the same paths."""
european = np.maximum(K - paths[:, -1], 0.0) * DISC_FULL
beta = np.cov(value, european)[0, 1] / european.var(ddof=1)
adjusted = value - beta * (european - bs_price(call=False))
return adjusted.mean(), adjusted.std(ddof=1) / np.sqrt(len(value))
if __name__ == "__main__":
steps = 50
reference = crr_bermudan_put(5000, steps)
american = crr_bermudan_put(5000, 5000)
print(f"Put with {steps} exercise dates: binomial tree {reference:.5f}. Continuous exercise: {american:.5f}\n")
print("In-sample: the policy is fitted and valued on the same paths. Out-of-sample: valued on fresh paths.")
print("Both estimates use the European put as a control variate.")
print(f"{'Paths':>8} {'Degree':>7} {'In-sample':>10} {'Out-of-sample':>14} {'Std error':>10} {'Error (out)':>12}")
rng = np.random.default_rng(17)
for n in (5_000, 50_000, 500_000):
train = simulate(n, steps, rng)
test = simulate(n, steps, rng)
for degree in (1, 2, 3, 4):
coefficients, _ = fit_policy(train, degree)
in_sample = with_control(apply_policy(train, coefficients), train)[0]
est, se = with_control(apply_policy(test, coefficients), test)
print(f"{n:>8,} {degree:>7} {in_sample:10.5f} {est:14.5f} {se:10.5f} {est - reference:+12.5f}")
print("\nDegree 3, 500,000 paths: more exercise dates")
print(f"{'Dates':>6} {'LSM (out-of-sample)':>20} {'Std error':>10} {'Tree':>9}")
for dates in (2, 5, 10, 50, 100):
train, test = simulate(500_000, dates, rng), simulate(500_000, dates, rng)
coefficients, _ = fit_policy(train, 3)
est, se = with_control(apply_policy(test, coefficients), test)
print(f"{dates:>6} {est:20.5f} {se:10.5f} {crr_bermudan_put(5000, dates):9.5f}")
The output is:
Put with 50 exercise dates: binomial tree 6.73535. Continuous exercise: 6.74280
In-sample: the policy is fitted and valued on the same paths. Out-of-sample: valued on fresh paths.
Both estimates use the European put as a control variate.
Paths Degree In-sample Out-of-sample Std error Error (out)
5,000 1 6.60254 6.70160 0.06395 -0.03375
5,000 2 6.64869 6.71268 0.06742 -0.02267
5,000 3 6.68139 6.70801 0.06738 -0.02735
5,000 4 6.72520 6.71999 0.06558 -0.01536
50,000 1 6.66343 6.64737 0.01970 -0.08799
50,000 2 6.69683 6.73221 0.02107 -0.00314
50,000 3 6.72521 6.73887 0.02119 +0.00352
50,000 4 6.72041 6.73394 0.02114 -0.00142
500,000 1 6.65616 6.67460 0.00627 -0.06076
500,000 2 6.71357 6.72472 0.00665 -0.01063
500,000 3 6.73098 6.74218 0.00665 +0.00682
500,000 4 6.73249 6.74373 0.00663 +0.00838
Degree 3, 500,000 paths: more exercise dates
Dates LSM (out-of-sample) Std error Tree
2 6.59030 0.00534 6.58940
5 6.66700 0.00622 6.67362
10 6.69908 0.00645 6.70691
50 6.72924 0.00663 6.73535
100 6.73537 0.00667 6.73906
Reading the output:
A linear basis is not enough. With degree 1 the price is 0.06 to 0.09 below the tree at 50,000 and 500,000 paths, which is about 4 to 10 standard errors. The continuation value of a put is curved, and a line cannot follow it.
Degrees 3 and 4 agree with the tree. With 500,000 paths the out-of-sample prices are 6.742 and 6.744 against 6.735, within about 1.3 standard errors of the reference. The standard error of 0.0066 is the sampling noise of the test paths.
The price improves with the number of paths. At 5,000 paths the standard error is 0.065 and the prices vary by 0.02, which is no better than noise. With 50,000 paths the degree 2 to 4 prices are within 0.004 of the tree.
In-sample and out-of-sample prices are close here. The in-sample figure is not systematically above the out-of-sample one, as the theory of a foresight bias would suggest. At these sizes the difference is within the sampling error of 0.02 to 0.07 for 5,000 to 50,000 paths. The foresight bias grows with the number of regression coefficients relative to the paths, so it matters most for a rich basis on few paths, and the out-of-sample test is the safe one.
More dates give a higher price, 6.590, 6.667, 6.699, 6.729 and 6.735 for 2, 5, 10, 50 and 100 dates, tending to the American value of 6.743. The method is within 0.008 of the tree, below it in four of the five cases and mostly within about one standard error, as a low-biased estimate should be.
The control variate helps. The European put, which has an exact price, cut the standard error of the 500,000-path estimate from 0.011 to 0.0066.
A valuation control view#
Value the exercise rule out of sample: the in-sample price can be biased up, and an independent run, with a different seed, is the cheap test. A price that falls when it is revalued on fresh paths is a warning.
Test the basis: increase the degree and the paths, and check that the price is stable. A price that keeps moving with the basis is not converged. Check the continuation value near the exercise boundary, where the decision is made.
Compare with a tree or a grid on a simplified case: one factor and the same model. This is the test of the implementation, as in the example. Applied to a Bermudan swaption it is the Monte Carlo check of Interest Rate Mean Reversion, Part 4: Risk & Reserves.
Treat the result as a lower bound: the true price is above it by an unknown amount. The bias is smaller with a better basis, and an upper bound can be computed by a dual method when it is needed.
Look at the exercise behaviour: the fraction of paths exercised on each date and the implied boundary should be smooth and plausible. A jagged boundary is a sign of too few paths or a poor basis.
Next, Advanced Methods, Part 2: Dimension, Adjoints & Machine Learning covers what happens as the number of factors grows, and how risk is computed for large books.