← All projects

Technology

Pricer mutation lab

Sixteen realistic bugs injected into a Black-Scholes pricer, and which tests actually catch them.

A pricer is hard to test because you usually do not know the right answer. So teams rely on a reference price and on no-arbitrage rules such as put-call parity. I wanted to measure how much protection those checks really give.

Mutation testing does this by breaking the code on purpose. Here, 16 realistic bugs are written as exact edits to a Black-Scholes pricer, and 11 kinds of check run against each one. Each check runs on up to 300 random inputs and reports the first input that fails. Choose a test suite below and see which bugs still reach production.

Loading the model…

What I found

One reference price at one year catches 3 of the 16 bugs. Put-call parity catches 4. Together they let 11 through, and this is a common starting point for a test suite.

Parity is weaker than it looks because of how the formula is built. It reduces to N(x) + N(-x) = 1, which holds for any x, so a wrong d2 passes it to the last decimal. The bug that replaces the square root of time with time also passes the textbook case, since the two are equal at one year.

The best single check is comparing delta with a bump of the price, at 9 of 16, and it still misses 7. No check catches everything. Bugs in a Greek only show up against a bump, and bugs in the zero-volatility guard only show up at the limits. A greedy search found a suite of six checks that catches all 16.

The doubling check caught nothing. Black-Scholes depends only on the ratio of spot to strike, so none of these bugs can break it. I kept it in the results, because a check that catches nothing is a finding too.

What it leaves out

I chose the bugs by hand, so the scores describe this list and are not a general measure of each check. The six-check suite comes from a greedy search and may not be the smallest possible.

Personal project built with synthetic data. It uses nothing from any employer, and it is not investment advice.