Skip to content
Module 10 of 1055 min readAdvanced

Numerics in production

Reproducibility, regression tests, the pre-trade pricing sandbox, what a quant developer actually ships when they 'add a model' to a pricing library.

100%

Listen along

Read “Numerics in production” aloud

Plays in your browser using on-device text-to-speech — nothing leaves the page.

Numerics in research code is one thing. Numerics in production — where prices feed risk reports, settlements, and capital calculations — is a different discipline. Reproducibility, regression testing, audit trails, performance monitoring, and graceful degradation are essential. This module covers what a quant developer ships when they 'add a model' to a production library.

Reproducibility

  • Pin random seeds: every MC simulation should produce identical output when re-run.
  • Pin library versions: numpy 1.26.0, not 'latest'. Floating-point ops can change subtly across versions.
  • Pin platform: x86 vs ARM, Linux vs Mac can give last-bit differences. Document the test environment.
  • Pin data: cache input snapshots so a model's output can be reproduced from inputs preserved at decision time.

Regression testing

Maintain a corpus of pricing tests: (model, parameters, expected price). On every code change, re-run the corpus and flag any test where price moves beyond tolerance. Distinguish:

  • Intended changes: an explicit bug fix should change specific test values; document and accept.
  • Unintended changes: a refactor or library upgrade should leave prices unchanged. Investigate any movement.
  • Tolerance: typical pricing tolerance 1e-6 to 1e-10 relative; tighter for closed forms, looser for MC.

Performance monitoring

  • Track latency per pricing call. Alert on regressions.
  • Track standard error of MC pricers. Latency might be acceptable but accuracy degraded.
  • Track solver-convergence diagnostics: iterations, residuals.
  • Profile in production: where is time actually spent? Often the answer surprises — model-fit code is 5%, marshalling/serialisation is 50%.

Graceful degradation

When the high-accuracy method fails (timeout, numerical issue), what does the system do?

  • Fall back to a coarser MC or PDE grid with explicit lower-accuracy flag.
  • Use a closed-form approximation (Black-Scholes for an exotic) and flag the result.
  • Return last-good price and flag stale.
  • Refuse to price and flag for human review.

Never silently return an incorrect price. The path between a numerical failure and a trade ticket is the path along which firms lose money.

Calibration and re-calibration

Production models are calibrated to market data daily (or intraday). The calibration process — typically a non-linear optimisation — must converge reliably, deliver economically reasonable parameters, and produce stable risk numbers day-over-day. Common issues:

  • Multiple local minima: pin to global by warm-starting from yesterday's solution.
  • Boundary parameters: model jumping from interior to boundary changes risk numbers discontinuously.
  • Calibration noise: small market-data perturbations producing big parameter changes. Regularise.
  • Stress events: calibrating to crisis vol surfaces requires guardrails to prevent runaway parameters.

Audit trail

For every priced trade in a regulated context (basically anything that ends up on a bank's balance sheet), maintain: trade specification, model name and version, parameter snapshot, market data snapshot, pricing time, computed PV and Greeks, MC convergence diagnostics. This is a regulatory requirement and an operational lifesaver during audits or P&L investigations.

Testing the model

  • Closed-form sanity checks: model prices reduce to known closed forms at limits (zero vol, zero rate, very long horizon).
  • Cross-method validation: PDE price ≈ MC price ≈ tree price within tolerance.
  • Put-call parity: P - C = K·exp(-rT) - F. Always check.
  • Cross-strike monotonicity: call price strictly decreasing in K; put strictly increasing.
  • No-arbitrage relations: gamma ≥ 0; calendar-spread non-negativity.

Versioning

Every model has a version string in its name (BS_v2_3). Deprecate old versions with grace periods. Maintain backward compatibility for already-traded books. When introducing a new version, validate on the historical corpus and document the differences in detail.

Handover documentation

When a quant developer leaves the firm, the next person should be able to: (1) run the model from a checkout, (2) understand the parameter conventions, (3) reproduce the regression tests, (4) calibrate to today's market. Documentation is the difference between a 2-week handover and a 6-month one.

The quant-developer job description

A senior quant developer at a tier-1 bank or hedge fund is the person who makes sure that the maths in research papers, the algorithms in academic textbooks, and the calibrations of yesterday's market data become a system that prices trades correctly at 3:47 a.m. on a Friday in March when the calibration converges slowly and three other systems are down. The numerics in this course are the start; production engineering is the finish.

Where to go next

  • Stochastic Calculus: the theoretical foundation under all of this.
  • Portfolio Theory and Optimization: the buy-side counterparts to derivatives quant.
  • Python course: the language production numerics is most often written in (alongside C++).
  • Engineering: software architecture, distributed systems, latency optimisation.

Exercise

A new exotic-option model is ready to deploy. Outline a pre-deployment checklist that demonstrates the model is fit for production use.

Loading progress…
LeadAfrikPublic Economics Hub