Follow the build from the first option price to the published risk dashboard. Each day pairs an implementation decision with a check and a traceable project artifact.
04 weeks28 calendar entriesOCT 11 – NOV 07 / 2026
Calendar note. The dates are illustrative. This reconstructed walkthrough follows the order of the technical work. Measured sample and backtest dates appear separately in the analysis.
Interactive extension · 30 simulated sessions
Try the portfolio as a trader.
Choose XIU or the USD/CAD straddle and place a simulated buy or sell using CAD paper cash. Advance one session to track marked-to-market P&L and see how your positions respond to a +2% USD/CAD stress.
Define the exposures, align public observations and validate the instruments before estimating a loss distribution.
Day 01
Define the reference book
Size the CAD 10M book at CAD 5M in XIU, CAD 3M in a 5Y GoC bond and CAD 2M in a 10Y GoC bond. Sell a 3M USD/CAD call and put at the same spot-ATM strike, with USD 15M notional per leg. Retain the premium as CAD cash.
Check. Check that the cash and option liability offset at inception and that opening NAV ties to CAD 10M.
Map XIU and USD/CAD closes to Yahoo Finance, GoC zero yields and CORRA to the Bank of Canada, and the 3M U.S. Treasury rate to FRED. Set prices, rates and volatility to consistent units. Treat CAD per USD as the spot quote.
Check. Record series names, sample dates and a checksum for the locally downloaded panel.
Intersect the observed equity, FX and GoC curve dates. Attach the latest strictly prior CORRA and DGS3MO observations within seven calendar days. Preserve the distinction between observation date and publication date for the lagged GoC curve.
Check. Use a small fixture with a missing close and same-day carry observations to verify the joint calendar and strictly prior rate matching.
Compute USD/CAD log returns and seed daily variance with the first 30 squared returns. Update variance with 0.94 persistence and annualize with 252 sessions. Feed the resulting realized-volatility proxy to the option model.
Check. Check the seed and next recursive update by hand, and make sure later observations cannot change earlier volatility values.
Use Garman–Kohlhagen with the CAD proxy as domestic carry and the USD proxy as foreign carry. Price the call and put independently. Derive spot delta, gamma, vega and theta, with additional curvature terms for joint FX and volatility moves.
Check. Compare the four primary Greeks with finite differences. Verify put–call parity and intrinsic value at expiry.
Construct semiannual coupons and principal for synthetic 5Y and 10Y bonds. Interpolate zero rates across the five available knots and discount each flow at its own tenor. Compute parallel DV01 and convexity, and isolate 5Y and 10Y key-rate exposures.
Check. Check that the par coupon prices each opening bond at face value. Bump the curve to verify the direction and magnitude of local rate sensitivities.
Combine equity, bonds, FX options and cash in one valuation interface. Keep position sizes fixed within a historical test. Reset the strike for each risk snapshot and hold the strike fixed when measuring the following shock.
Check. Compare the vectorized repricer against individual valuations. Keep daily snapshot marks separate from held one-day P&L with carry and elapsed time.
Build four model families on the same five-factor shock convention and isolate what changes when option curvature enters the valuation.
Day 08
Define the shock vector and loss sign
Use log moves for XIU and USD/CAD, and absolute decimal changes for the 5Y and 10Y zero yields and FX volatility. Keep short-end curve knots, funding proxies and tenor fixed within modeled shocks. Express risk as positive CAD losses.
Check. Verify all five factor coordinates against finite differences of the portfolio, including the FX-volatility cross term.
Revalue the held portfolio under each of the preceding 500 observed joint shock vectors. Read 99% VaR from the empirical loss quantile and compute 97.5% ES by averaging the upper tail with fractional mass where the cutoff crosses a sample point.
Check. Test fractional tail weighting and document that only about five observations lie beyond the historical 99% threshold.
Project the sample shock mean and covariance through the portfolio gradient. Use the resulting normal distribution for the loss quantile and tail average. This gives a baseline with the same calibration as Gaussian simulation.
Check. Compare with the closed form for a linear exposure. Add an at-zero-delta short-gamma case where a linear model misses the quadratic loss.
Build a quadratic loss approximation from the gradient and Hessian. Compute its cumulants under Gaussian shocks and adjust the quantile with Cornish–Fisher. Sort the adjusted quantile grid when the approximation is nonmonotone.
Check. Use a noncentral chi-square case to check the quadratic cumulants with a nonzero shock mean. Check behavior when Cornish–Fisher needs rearrangement.
Correlate 10,000 standard normal draws with the Cholesky factor of the estimated covariance and apply full repricing to every path. Reuse seeded base draws for comparisons across dates and valuation methods.
Check. Check the fallback for a singular covariance matrix so deterministic factor directions retain zero variance.
Give the Gaussian innovations a common per-path Student-t scale with six degrees of freedom. Rescale to match the Gaussian covariance. Run the same full repricer so the comparison isolates the joint shock distribution.
Check. Verify the shared path scale and covariance adjustment. Label Gaussian and Student-t as two variants of one Monte Carlo model family.
Compare linear and full-revaluation VaR on identical Gaussian paths. Repeat with the same equity and bond book and the option position removed. The paired VaR shortfall is 2.6% with the straddle. Linear VaR is slightly higher in the control.
Check. Keep the paired result separate from the 4.3% gap between analytical delta-normal and simulated full revaluation.
Run a strictly out-of-sample forecast loop, test coverage and clustering, then replay crisis shocks on the report-date portfolio.
Day 15
Freeze the rolling forecast protocol
Backtest 750 realization dates from October 11, 2023 through October 21, 2026. For each date, fit all model variants to the preceding 500 aligned shocks. Form the portfolio snapshot from the prior observation, then score the next realized shock.
Check. Assert that the training slice excludes the realization. Count an exception only when the realized loss strictly exceeds forecast VaR.
Count 99% VaR exceptions for each model and compare the observed frequency against 1% using the Kupiec likelihood ratio. Keep the count, rate, statistic and p-value in the same diagnostics table.
Check. Review the probability-boundary fixtures, including all-hit and no-hit sequences. Compare 12 delta-normal breaches with 8 historical simulation breaches.
Build the four no-hit/hit transition counts for each model. Apply the Christoffersen independence and conditional coverage tests to see whether exceedances arrive independently and at the target frequency.
Check. Use a fixture with equal exception counts but different ordering. In the empirical sample, all five variants flag clustering at 5%.
Classify the final 250 forecasts using Basel-style bands of 0–4 green, 5–9 amber and at least 10 red. All five variants fall in the green band. Keep the full-period independence result visible alongside the traffic light.
Check. Check the four band boundaries and verify that earlier exceptions do not enter the final-250 count.
Hold other factors constant and sweep USD/CAD spot up and down. Plot exact, delta-only and delta-gamma P&L. At a +2% move, delta alone gives a CAD 69.7k gain while full repricing gives a CAD 73.7k loss.
Check. Check the zero-shock origin and show where a local quadratic begins to overstate the loss at larger moves.
Apply historical spot, rate and volatility changes since each episode’s preceding close to the same report-date book. Replay September–November 2008, March 2020 and calendar 2022 at fixed strike and tenor.
Check. Record end-of-period P&L and worst observed close separately. The 2008 replay’s worst close gives a CAD 6.16M loss.
Bump the CAD curve and CAD option carry proxy by 200 bp, depreciate the CAD by 10% in USD terms, and double FX volatility. Apply the shocks separately and then reprice their combined effect.
Check. Translate the CAD depreciation to an 11.11% increase in USD/CAD. Reconcile total and position-level P&L for the CAD 2.51M combined loss.
Extend the data context, explain model boundaries and turn the empirical study into a reproducible public demonstration.
Day 22
Document valuation conventions
Separate the one-day forecast loss, realized hypothetical backtest loss and held one-day carry-inclusive P&L. Explain why the bond tenors are refreshed for a new snapshot and why that mark series is distinct from an investable roll strategy.
Check. Tie the definitions back to the analysis code and note the flat carry proxies, the lack of a volatility smile and the BoC publication lag.
Pull the Bank of Canada Valet FXUSDCAD series as an independent daily CAD-per-USD reference. Compare overlap, daily return correlation and gaps against Yahoo on matched observations. Keep the existing valuation feed unchanged.
Check. The same-date return correlation is 0.37 across the common return sample. Comparing the BoC return with the next matched Yahoo session raises correlation to 0.75 on a common comparison slice, a timing diagnostic consistent with different observation windows. The Yahoo date labels in the model stay as supplied.
Download CBOE VIX from FRED and match each test date to the latest strictly prior observation within seven days. Split the existing backtest at VIX 20 and compare exception counts and rates by regime.
Check. Delta-normal breaches on 6 of 623 days below VIX 20 and 6 of 127 days at or above it. This post-hoc split describes the backtest. VIX measures U.S. equity implied volatility and stays outside the risk factors.
Package the one-day risk snapshot, the paired Gaussian comparison, coverage diagnostics and stress outputs. Present the difference between a model’s total exceptions, their clustering and its final-250 classification.
Check. Link the notebook and summary tables to the underlying scripts and include commands for a fresh clone to reproduce the study.
Expose the FX shock sweep alongside the model comparison and stress explorer. Use the Python engine’s computed outputs so the website and report share the same numbers.
Check. Check the sign conventions, shock bounds and readable chart labels. Make the controls usable with a keyboard.
Run pricing, alignment, simulation and backtest tests together. Confirm the website uses derived results and study metadata. Keep the full raw-price panel in the local workspace.
Check. Verify the clean-checkout instructions and confirm the published files do not include credentials or local market caches.
Serve the public demonstration from the repository and connect the README, the live model lab and this development walkthrough. Give visitors a path from each empirical claim to the supporting table or implementation.
Check. Check the deployed dashboard, the four-week navigation and the GitHub links on a narrow and a wide screen.