A floating-point function that "looks about right" is not tested. Numerical code needs oracles: a closed form, a finite-difference bump, an algebraic invariant (put–call parity, probabilities that sum to one), and a stated tolerance. Seeds turn stochastic routines into replayable checks. This lesson builds that toolkit for the curve and Black–Scholes objects from object-oriented model design.
Learning objectives. By the end of this note you should be able to:
- write a closed-form regression test with an absolute or relative tolerance;
- check a first-order Greek by central finite differences;
- encode put–call parity and a discrete probability simplex as asserts;
- seed Monte Carlo so a test fails for logic bugs, not for fresh noise.
In this lesson
- Oracles beat vibes
- Invariants
- Finite-difference bumps
- Seeded randomness
- A minimal pytest-shaped layout
- Table of oracle types
Before you start
The full lesson, with worked examples and exercise solutions, is for members.
Read the full lessonNew to SelfMadeQuant.com? See membership options or browse the Python for Quantitative Finance syllabus.