Jide Oyelayo
CV

Work / 1.3 Option pricing study

Case study 1.3 · Quant

Option pricing study

Black–Scholes prices and Greeks, implied volatility and Monte Carlo pricing in C++, each with an independent check and the Monte Carlo error measured against the number of paths.

Date
Nov 2026
Role
Author
Stack
C++17

Status: published. Certainty: Every figure is from the study in black-scholes-options pull request #1, run single-threaded on one Apple M1 Pro with Apple clang 21 and libc++; two full runs gave byte-identical results. Seeded Monte Carlo values would differ with another standard library; the statistics should not, but that was not run.

Summary

This is a small study of European option pricing, built on a 2024 C++ project, black-scholes-options, which prices options with the Black–Scholes model and computes the Greeks. The study audits that code, adds an implied-volatility solver and a Monte Carlo pricer, and shows the error alongside every answer. It is in pull request #1, and its results are in bench/RESULTS.md.

Every check passes. The Greeks agree with finite differences on a 630-point grid, put–call parity holds to 2.8 × 10⁻¹⁴, and the solver recovers the volatility in all 404 well-conditioned cases. The Monte Carlo error falls as the inverse square root of the number of paths, and its 95% interval covers the closed-form price in 94.65% of runs. The audit found the 2024 code’s prices and Greeks correct wherever σ√T > 0, and defects at the edges, listed under what went wrong.

Context and constraints

Pricing a European option with a closed form is easy to get subtly wrong: a sign in a Greek, a solver that fails at the edges, a Monte Carlo estimate quoted without its uncertainty. The study makes each of those failures visible by pairing every method with an independent check.

The scope is deliberately narrow. The choices below were fixed before the first run and not changed after it.

Operating limits
LimitValue
Option style and payoffEuropean calls and puts; no early exercise
Dividends and ratesA constant rate and no dividends, as the code implements
Parameter ranges for the tests630 points: K = 100; S from 50 to 200; T from one day to 5 years; volatility from 1% to 300%; r of 0, 3% or 10%; each priced as a call and a put
Tolerances for each checkParity residual at most 10⁻¹⁰ × K; each Greek within 10⁻⁶ relative plus 10⁻⁸ absolute of a central difference (gamma 10⁻⁵ plus 10⁻⁶); solver within 10⁻⁶ vol points wherever vega is at least 10⁻⁵ per point
Random-number generator and seedsstd::mt19937_64 with libc++’s std::normal_distribution; seeds 1 to 1,000 at every path count; the unit checks use seeds 42 and 7

My role

I am the author of the 2024 pricer linked above. The study adds a CMake build, tests, the solver, the Monte Carlo pricer and the report to that repository, in pull request #1. It is written in C++17 to match the existing code; Python is used only to draw the repository’s own figure. I am not claiming any use of these methods in practice.

Architecture

The study has three parts that share one set of inputs. A closed-form Black–Scholes module returns a price and its Greeks. A solver inverts that price to recover implied volatility. A Monte Carlo module estimates the same price by sampling the terminal spot exactly, with no variance reduction, and returns it with its standard error and 95% interval. Because all three use the same inputs, they can be checked against one another.

The curve below is the closed-form call value against the spot price, the object the Greeks differentiate, as computed by the study.

50K = 10015003060C(S), T = 1yσ = 20%payoffat expiry
Fig. 1 Black–Scholes call value against spot Closed-form call value against spot, every fifth row of bench/call_curve.csv; K = 100, σ = 20%, r = 3%, T = 1. The dashed line is the payoff at expiry.

Key decisions

Finite differences check the Greeks. Each analytic Greek is compared with a central finite difference of the price. The criterion is independence: the check uses only the pricing function, not the formula under test. The cost is a step-size choice, which trades truncation error against rounding. The steps scale with the width of the price curve, w = Sσ√T: 10⁻⁴w for delta, 10⁻³w for gamma, 10⁻⁴ in volatility for vega and 10⁻³T for theta.

Newton with a bisection fallback. Implied volatility is found by Newton’s method from the Manaster–Koehler starting point, and by bisection when a Newton step leaves the bracket of 0% to 1,000% or fails to halve the price error. It stops at 10⁻¹⁰ vol points or 100 iterations. Bisection alone is robust but slower; Newton alone can diverge when vega is small. The cost is one more code path to test.

Parity as a unit test. For a European call and put on the same underlying, strike and expiry without dividends, the call price minus the put price equals the spot minus the discounted strike. This identity is tested directly because it needs no simulation and fails loudly if a pricer is wrong.

Monte Carlo with its band. The estimate is reported with a 95% interval, 1.96 standard errors either side, plotted against the number of paths on log axes so the narrowing is visible. The cost is a larger run for each extra digit of precision, which the plot shows rather than hides.

Evaluation and results

Method what is measured, and how

Question
Do the closed-form price, Greeks, solver and Monte Carlo estimate agree with one another, and how large is the Monte Carlo error?
Checks
Finite-difference Greeks, solver round trip and put–call parity over the grid: 8,006 checks, 0 failed; 11 Monte Carlo unit checks, 0 failed
Inputs
The 630-point grid above; Monte Carlo on the call with S = K = 100, σ = 20%, r = 3%, T = 1, closed form 9.413403383853
Controls
Seeds 1 to 1,000 at each of 11 path counts from 10² to 10⁷ in half decades (11,000 runs); the same inputs across methods; two full runs gave byte-identical results
Environment
Apple M1 Pro, macOS 27.0.1; Apple clang 21.0.0 with libc++, CMake 4.4.0, Release (-O3 -DNDEBUG -std=c++17); single thread
Reported
RMS error, median absolute error and mean reported standard error against paths, with least-squares slopes; coverage of the 95% interval, with a binomial interval
Reproduce
bench/run.sh builds, runs the tests and the study, and draws the figure: about 8 minutes on the M1 Pro
Not claimed
Speed (nothing is timed), the same seeded values with another standard library, accuracy beyond the tolerances tested, a model of real markets, or suitability for trading or risk.

Greeks and parity. Over the grid, for calls and puts, the worst put–call parity residual is 2.842 × 10⁻¹⁴ against a tolerance of 10⁻⁸, and delta parity holds exactly. The worst finite-difference error, as a fraction of its tolerance, is 0.014 for delta, 0.057 for gamma, 0.060 for vega and 0.901 for theta. Theta passes with the narrowest margin; its step stays as declared before the run.

Implied volatility. In the 404 well-conditioned cases, the worst error is 2.9 × 10⁻¹⁰ vol points, with a median of 5 iterations and a maximum of 19. Of the 226 ill-conditioned cases, 157 are rejected because the price sits exactly on a no-arbitrage bound in double precision. The other 69 are solved, but 39 miss the volatility by more than 10⁻⁶ points, by up to 22.18 points at S = 120, one day to expiry and 1% volatility. Their vega is at most 6.2 × 10⁻⁹ per point, so the price does not determine the volatility in double precision; every solved case reproduces its price to within 2.842 × 10⁻¹⁴. No case failed to converge.

Monte Carlo. The RMS error over 1,000 seeds falls from 1.4460 at 100 paths to 0.0043825 at 10⁷, a log–log slope of −0.5026 ± 0.0008 against the expected −1/2. The ± is the standard error of the fit; it understates the uncertainty, because each seed’s longer runs extend its shorter ones. The reported standard error is within 3% of the actual RMS error at every path count. The 95% interval contains the closed-form price in between 0.939 and 0.953 of runs at each path count, and in 10,412 of 11,000 runs overall (0.9465).

Black–Scholes value9.413495% band81012141610²10³10⁴10⁵10⁶10⁷call price estimatenumber of simulated paths, log scale
Fig. 2 Monte Carlo estimate against number of paths Seed 1's estimate with its 95% interval against paths on log axes, from bench/mc_raw.csv; the rule is the closed-form value. At 3,162 paths the interval misses it, as about one interval in twenty should.

What went wrong and limits

The audit ran the new pricing tests against the 2024 headers: 57 of 8,006 checks failed. The closed-form prices and Greeks were right wherever σ√T > 0. The defects were at the edges:

  • the repository did not link, because functions defined in the headers were not inline;
  • the price was NaN exactly at the strike at expiry, and at the forward with zero volatility; gamma was NaN at expiry or zero volatility at any spot, and theta at expiry;
  • Option::set_strike and set_expiry threw before assigning, on every call;
  • the old implied-volatility solver returned NaN on 43 of the 404 well-conditioned round trips: 30 at the forward with r = 0, and 13 with σ√T of at least 1.5, where its starting guess is negative. It also accepted a zero or negative price for an out-of-the-money call, and its loops had no iteration cap.

Pull request #1 fixes each of these and replaces the solver. At the strike itself at expiry the Greeks are undefined and stay NaN. The old README described files and classes that did not exist, and its build steps could not work; it is rewritten.

Monte Carlo was run for one option; other strikes and expiries are covered only by the unit checks at 10⁶ paths. Nothing is timed. The seeded values depend on libc++‘s normal distribution, so another standard library would give different numbers; the statistics should carry over, but that was not run. The study covers European options under constant parameters. It does not cover dividends, early exercise, stochastic volatility, transaction costs or calibration to market data. Parity and finite-difference checks show internal consistency, not that the model describes a market.

Next

Time the pricers, and run the study with libstdc++ to confirm that the statistics carry over. Extend the Monte Carlo study to other strikes and expiries, each with the same error and coverage figures.