Calculators look simple until two of them disagree by a cent. We publish free options and stock calculators at headroomdesk.com, and the rule we hold ourselves to is that every number on the page can be reproduced by an independent implementation.

Two implementations, one set of answers

The browser engine is plain JavaScript. A separate Python reference computes the same quantities: money at expiry with exact integer and fraction arithmetic, and model values (Black-Scholes, Greeks, implied volatility) with the same fixed normal-distribution algorithm, so the two agree to about one part in a trillion. A generator writes 3,123 test vectors (strategies, strikes, premiums, days, volatility, rates) with the reference's answers, and CI replays all of them against the JavaScript on every deploy. A release fails if a value differs beyond its stated rounding.

Exact money, not floating point

0.1 + 0.2 is not 0.3 in floating point, and a calculator that shows 597.9999999 erodes trust fast. Prices are read as whole numbers of a hundredth of a cent. Our stock and forex pages keep every input as a BigInt fraction, so totals are exact and rounding happens once, at display, half away from zero. The forex lot size calculator goes one step further: the size is the exact quotient rounded down to the lot step, and a test checks 3,000 random cases that the loss at the stop never exceeds the risk typed, and that one more lot step always would.

Saying what the model does not know

Black-Scholes values for American options are approximations; the page says so in a fixed sentence that the build checks is present. Results at expiry are exact; values before expiry are model estimates. Fees, early assignment and dividends are listed as not included.

The same engine for AI assistants

The engine also runs as a read-only MCP server, so an assistant can call it instead of doing arithmetic in its head. It is listed in the official MCP Registry as io.github.headroomdesk/calculators, and the code is MIT on GitHub (headroomdesk/calculators).

What we would do again

  • Write the reference first, in a different language, before the UI.
  • Keep the test vectors in the repo so anyone can rerun them.
  • Treat a missing caveat as a failing test.

The calculators: https://headroomdesk.com/calculators/
The repo: https://github.com/headroomdesk/calculators

Drafted with an AI assistant and checked against the code by the Headroom Desk team.