Chapter 5 Laboratory — Module 5: Fair Games, Measure Change, and Dynamic Hedging¶

Mathematical Foundations of Modern Finance · Part I · Week 5

Three panels: a fair-game sandbox, a measure panel (the density process $Z_t$, and $E_Q[H]/R^T = E[ZH]/R^T$), and a hedging simulator (the $(V,\Delta)$ lattice by backward induction).

Seeds: 20260501–20260503.

In [1]:
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams.update({"figure.figsize": (7, 4.2), "axes.grid": True,
                     "grid.alpha": 0.3, "font.size": 11})
BRASS, INK = "#B4884A", "#0F1E3D"
import mfmf_engine_ch05 as eng

E1 — You cannot beat a fair game (supports LOS 5.2)¶

Predictable betting rules — stakes fixed by the visible history — average to zero within error bands. A one-step peek (illegal foresight) buys a positive slope.

In [2]:
r1 = eng.E1_fair_game()
print(f"Predictable rule mean gain : {r1['predictable_mean_gain']:+.4f} "
      f"(± {r1['predictable_se']:.4f})")
print(f"Peek (foresight) mean gain : {r1['peek_mean_gain']:+.4f}")
print(f"Peek buys a positive slope : {r1['peek_buys_positive_slope']}")

fig, ax = plt.subplots()
ax.bar(["predictable", "with peek"],
       [r1['predictable_mean_gain'], r1['peek_mean_gain']],
       color=[INK, BRASS])
ax.axhline(0, color="grey", lw=1)
ax.set_ylabel("average gain"); ax.set_title("E1: fair game averages to zero; foresight pays")
plt.tight_layout(); plt.show()
Predictable rule mean gain : -0.0087 (± 0.0045)
Peek (foresight) mean gain : +2.8571
Peek buys a positive slope : True
No description has been provided for this image

E2 — Change of measure and the density process (supports LOS 5.3–5.4)¶

The density process $Z_t$ is a strictly positive $P$-martingale with $Z_0=1$. Pricing by $E_Q[H]/R^T$ and by $E[Z H]/R^T$ gives the same number along every path.

In [3]:
r2 = eng.E2_measure_change()
print(f"Call price by E_Q[H]/R^T : {r2['call_by_Q']:.4f}")
print(f"Call price by E[Z H]/R^T : {r2['call_by_ZH']:.4f}")
print(f"Agree                    : {r2['agree']}")
print(f"Density: Z0={r2['density']['Z0']}, up-ratio={r2['density']['z_up_ratio']:.4f}, "
      f"E[Z]=1: {r2['density']['E_Z_is_1']}")
Call price by E_Q[H]/R^T : 17.4495
Call price by E[Z H]/R^T : 17.4495
Agree                    : True
Density: Z0=1.0, up-ratio=0.8333, E[Z]=1: True

E3 — The hedging lattice (supports LOS 5.5–5.6)¶

Backward induction produces the $(V,\Delta)$ lattice. The initial hedge ratio $\Delta_0$ is the replicating stock position the dealer must hold.

In [4]:
r3 = eng.E3_hedge()
lat = r3['call_lattice']
print(f"Call V0     : {lat['V0']:.4f}")
print(f"Call Delta0 : {lat['delta0']:.4f}")
print(f"Collar Delta0 (approx): {r3['collar_delta0_approx']:.4f}")
Call V0     : 17.4495
Call Delta0 : 0.7740
Collar Delta0 (approx): -0.7143

Validation checks¶

Every laboratory report must reproduce these; a report whose checks do not pass is returned ungraded.

In [5]:
checks = eng.validation_checks()
for k, v in checks.items():
    if k.startswith("_"): continue
    print(f"[{'PASS' if v else 'FAIL'}] {k}")
assert checks["ALL_PASS"], "Validation failed — do not submit."
print("\nAll Module validation checks pass.")
[PASS] V1_predictable_averages_zero
[PASS] V2_peek_buys_slope
[PASS] V3_measures_agree
[PASS] V4_density_Z0_and_mean
[PASS] V5_q_half
[PASS] ALL_PASS

All Module validation checks pass.