Susan Potter
### quant  ·  Created  ·  Updated

Metamorphic Relations for Backtests: Testing the Engine, Not the Strategy

I am reorganizing where my quantitative writing lives. Working notes on essays, ideas, and identity stay here on susanpotter.net. Longer-form technical work that maps directly onto the tooling my company builds is moving to referentiallabs.com/blog , where it sits alongside the services and platform pages it informs.

The metamorphic testing article has moved to Referential Labs: Metamorphic Relations for Backtests .

What the article covers

Traditional testing relies on knowing the correct output. Backtests break that assumption: there is no expected Sharpe ratio to compare against. Metamorphic testing solves this by shifting the question from “is the output correct?” to “does the output change correctly when the input transforms?” The article covers:

  • Why metamorphic relations catch bugs example-based tests miss: rounding errors that only appear at scale, cost calculations that work for single-leg trades but break for spreads, and position sizing logic that is correct for round lots but wrong for fractional shares.
  • Fee monotonicity: increasing transaction costs should never improve performance. The relation catches sign errors, inconsistent cost application, and threshold interaction bugs. Includes a Hypothesis property that generates random fee pairs and checks the invariant across many strategies.
  • Cash invariance: doubling initial capital while proportionally scaling positions should preserve the Sharpe ratio. Catches integer share rounding inconsistencies, fixed-cost components that do not scale, and non-linear position sizing bugs.
  • What these tests do not verify: they check engine mechanics, not strategy quality. Analogous to compiler unit tests, they confirm the tool works without validating what runs through it.

I first used this pattern building large-scale SaaS products where the same “no known correct answer” problem exists. My 2020 Haskell Love talk Thinking in Properties covers the same set of ideas applied to software systems.

Why the reorganization

The commercial site is where the tools and services these articles inform actually live. Colocating the writing with the tooling makes the site do a job it should always have been doing, and it lets me use susanpotter.net for the kind of writing that does not belong on a company site: essays, ideas, incidental notes.

Continue to the full article at Referential Labs .

Susan Potter

Susan Potter

Quant

Work with me

I spent the first half of my career building risk models and market data infrastructure at BNP Paribas, Bank of America, and Citadel, then fourteen years shipping production systems at scale. Now I bring both sides to quantitative trading. If you're a trading firm, family office, or fund looking to tighten the connection between your research ideas and your production trading systems, whether that's building validation pipelines, formalizing signal logic, or getting microstructure analytics into a deployable state, I'd like to hear what you're working on. Reach me at me@susanpotter.net.