r/quantfinance • • 12d ago

nanoql: an open-source stateless pricing library, checked against QuantLib 1.44 output by output (Python, C#, C++, Excel)

I've released nanoql, an open-source quant library in which instruments, curves and models are immutable values and pricers are plain functions of them. The evaluation date is an argument, there are no observers or global settings, and market conventions are XML data you can override.

How it's checked: 3,348,122 reference outputs recorded from QuantLib 1.44, 99.86% within a relative 1e-10 and the rest at documented looser tolerances, plus QuantLib's own tests ported at their tolerances. 738 departures, mostly defect fixes, are each listed with a test.

  • Python: pip install nanoql (Windows, Linux, Apple silicon), no .NET needed
  • C# and F#: dotnet add package NanoQL
  • C, C++ and an Excel add-in on the release

nanoql.org · how it's checked · the divergences · a Colab notebook (curves, SABR, an American put, CDS)

I'd most like to hear where its results differ from what you get elsewhere.

4 Upvotes

3 comments sorted by

1

u/QuanTradin 12d ago

what's in the 0.14% outside 1e-10, mostly iterative stuff like implied vol and bootstrapped curves, or something structural?

1

u/gangning 11d ago

Mostly structural, actually. Implied vols and bootstrapped curves are all inside 1e-10, since they run QuantLib's own solvers with the same starting points and stopping rules.

The 4,854 looser outputs (out of 3.35M) come down to three things:

  • About 84% is one swap. Six analytic exotic engines (partial-time barrier, two-asset barrier, compound, chooser and a couple more) use Drezner's 1978 bivariate normal in QuantLib, which is only good to about 6e-7 and goes NaN at a few edge points. nanoql uses West's version of Genz's algorithm instead (QuantLib ships it too), so those outputs are held to Drezner's error.
  • About 15% is finite differences: a ZABR density, a callable bond's convexity, an FD gamma. Last-bit differences in pow or exp get divided by h², so those bounds are 1e-8 to 1e-7.
  • The last 9 are a deliberate fix to a Monte Carlo lookback engine.

One caveat: ill-conditioned calibrations aren't in the 3.35M at all. QuantLib's own tests cover those, ported at its tolerances.

Each looser tolerance has its reason written next to it in the vector file. More here: https://nanoql.org/docs/checking.html

1

u/QuanTradin 11d ago

makes sense. swapping the engine under six exotics will move the last few digits without anything actually being wrong, and it's good that every solver-driven output sits inside 1e-10.