Chapter 8 Laboratory — Module 8: The Pricing Machine¶
Mathematical Foundations of Modern Finance · Part II · Week 8
Four panels: the PDE panel (finite differences vs Monte Carlo — Feynman–Kac split-screen), the Greeks panel, the smile panel, and the barrier panel. Reproduces Example 8.3: put(90) = 1.7228, call(110) = 4.4803, collar = −2.7574.
Seeds: 20260801–20260804.
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_ch08 as eng
E1 — The collar, three ways (supports LOS 8.1–8.2)¶
With $S_0=100$, $\sigma=17\%$, $r=3.98\%$, $T=1$: the closed-form Black–Scholes collar is $-2.7574$, and the Monte Carlo estimate of the Feynman–Kac expectation converges to the same value.
r1 = eng.E1_collar()
print(f"put(90) : {r1['put90']:.4f} (book 1.7228)")
print(f"call(110) : {r1['call110']:.4f} (book 4.4803)")
print(f"collar : {r1['collar']:.4f} (book -2.7574)")
print(f"Monte Carlo: {r1['mc']:.4f} ± {r1['mc_se']:.4f}")
put(90) : 1.7228 (book 1.7228) call(110) : 4.4804 (book 4.4803) collar : -2.7576 (book -2.7574) Monte Carlo: -2.7753 ± 0.0153
E2 — The Greeks and the jump-day P&L (supports LOS 8.3)¶
Read the dealer's collar gamma at $S=92$ and $S=100$, and the P&L a gamma position takes on a large gap day.
r2 = eng.E2_greeks()
for S, d in r2['by_S'].items():
print(f"S = {S}: collar gamma = {d['collar_gamma']:+.5f}, jump P&L (-8%) = {d['jump_pnl_-8pct']:+.4f}")
S = 92.0: collar gamma = +0.00356, jump P&L (-8%) = +0.0963 S = 100.0: collar gamma = -0.00769, jump P&L (-8%) = -0.2461
E3 — The volatility smile (supports LOS 8.5)¶
Reprice the collar with the put at $18.4\%$ and the call at $16.5\%$ — a downward skew. The fair value moves, and so does the zero-cost strike.
r3 = eng.E3_smile()
print(f"Collar at flat 17% vol : {r3['collar_flat']:.4f}")
print(f"Collar at skewed vols : {r3['collar_skewed']:.4f} (put {r3['put_vol']:.1%}, call {r3['call_vol']:.1%})")
print(f"Fair-value move : {r3['fair_value_move']:+.4f}")
Collar at flat 17% vol : -2.7576 Collar at skewed vols : -2.1947 (put 18.4%, call 16.5%) Fair-value move : +0.5629
E4 — Barrier knockout and monitoring frequency (supports LOS 8.6)¶
Price the dealer's knockout put ($B=80$) and compute its discount to the vanilla 90-put. Sliding monitoring from continuous to daily changes the price.
r4 = eng.E4_barrier()
print(f"Vanilla 90-put : {r4['vanilla_put']:.4f}")
print(f"Knockout (daily) : {r4['knockout_daily']:.4f}")
print(f"Knockout (continuous): {r4['knockout_continuous']:.4f}")
print(f"Discount to vanilla : {r4['discount_to_vanilla']:.4f}")
print(f"Monitoring gap : {r4['monitoring_gap']:+.4f}")
Vanilla 90-put : 1.7228 Knockout (daily) : 0.3286 Knockout (continuous): 0.2986 Discount to vanilla : 1.3941 Monitoring gap : +0.0300
Validation checks¶
Every laboratory report must reproduce these; a report whose checks do not pass is returned ungraded.
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_put90_1.7228 [PASS] V2_call110_4.4803 [PASS] V3_collar_-2.7574 [PASS] V4_mc_matches_closed_form [PASS] V5_smile_moves_value [PASS] ALL_PASS All Module validation checks pass.