<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Headroom</title>
    <description>The latest articles on DEV Community by Headroom (@headroomdeskadmin).</description>
    <link>https://dev.to/headroomdeskadmin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4257050%2F29e9e4b8-7664-4895-ab28-66e57956027f.png</url>
      <title>DEV Community: Headroom</title>
      <link>https://dev.to/headroomdeskadmin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/headroomdeskadmin"/>
    <language>en</language>
    <item>
      <title>How we test free trading calculators: 3,123 vectors and exact cents</title>
      <dc:creator>Headroom</dc:creator>
      <pubDate>Sat, 21 Nov 2026 09:46:33 +0000</pubDate>
      <link>https://dev.to/headroomdeskadmin/how-we-test-free-trading-calculators-3123-vectors-and-exact-cents-560a</link>
      <guid>https://dev.to/headroomdeskadmin/how-we-test-free-trading-calculators-3123-vectors-and-exact-cents-560a</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two implementations, one set of answers
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exact money, not floating point
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Saying what the model does not know
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same engine for AI assistants
&lt;/h2&gt;

&lt;p&gt;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).&lt;/p&gt;

&lt;h2&gt;
  
  
  What we would do again
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write the reference first, in a different language, before the UI.&lt;/li&gt;
&lt;li&gt;Keep the test vectors in the repo so anyone can rerun them.&lt;/li&gt;
&lt;li&gt;Treat a missing caveat as a failing test.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The calculators: &lt;a href="https://headroomdesk.com/calculators/" rel="noopener noreferrer"&gt;https://headroomdesk.com/calculators/&lt;/a&gt;&lt;br&gt;
The repo: &lt;a href="https://github.com/headroomdesk/calculators" rel="noopener noreferrer"&gt;https://github.com/headroomdesk/calculators&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Drafted with an AI assistant and checked against the code by the Headroom Desk team.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>testing</category>
      <category>mcp</category>
      <category>fintech</category>
    </item>
  </channel>
</rss>
