Crypto/stock backtester pipeline

See my other projects: turpin.dev.

Disclaimer

Don't invest what you can't afford to lose. Illustrations are for illustrative purposes only. History is not an indicator of future performance. That said...

Overview

Historic price data are fetched daily via the Marketstack and CryptoCompare APIs, and converted to CSV format using Python; each currency pair is then analysed in C++. Finally, the table below is generated using the trade summary.

Profiling

The C++ code is profiled using gprof and visualised with gprof2dot and graphviz.

gprof profile

Built with ♥ on Thu Oct 15 17:38:43 UTC 2026 by a Ubuntu Questing Quokka (development branch).

Backtests

  • 446 currency pairs (from Marketstack, Coinbase, Kraken, Binance)
  • 3% take profit
  • 6% stop loss
  • 68 candles window size
  • 0.5 minimum ATR (normalised)
  • 4.3 minimum entry price

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                51969 ns        51968 ns        13312
BM_is_entry2               39560 ns        39560 ns        17848
BM_to_exit                   231 ns          231 ns      3079395
BM_to_exit2                  233 ns          233 ns      3049355
BM_to_vwap                  5756 ns         5756 ns       121665
BM_to_vwap2                 5778 ns         5778 ns       120599
BM_is_recent_dip2            969 ns          969 ns       726211
BM_to_atr                  66552 ns        66552 ns        10422
BM_to_atr2                  3047 ns         3047 ns       230254
BM_to_atr3                  3017 ns         3017 ns       231033
BM_to_average_func         0.348 ns        0.348 ns   1998569618
BM_to_average_func2        0.364 ns        0.364 ns   1893722902
BM_to_average_volume       60747 ns        60747 ns        11619
BM_to_average_volume2       1661 ns         1661 ns       417697
BM_to_size                 0.521 ns        0.521 ns   1386168561
BM_to_first                0.353 ns        0.353 ns   2003500809
BM_to_last                 0.352 ns        0.352 ns   1995687377
BM_to_sum                  0.350 ns        0.350 ns   1996318378
BM_to_sum2                 0.350 ns        0.350 ns   1999436130
BM_to_spot                 0.354 ns        0.354 ns   1980428086
BM_identity                  123 ns          123 ns      5652301
BM_identity2                 123 ns          123 ns      5771725
BM_to_profit               0.350 ns        0.350 ns   2021601686
BM_to_time                 0.347 ns        0.347 ns   2009786870
BM_to_open                 0.363 ns        0.363 ns   1986295695
BM_to_high                 0.346 ns        0.346 ns   1972469622
BM_to_low                  0.362 ns        0.362 ns   1977829447
BM_to_close                0.348 ns        0.348 ns   1994885922
BM_to_volume               0.348 ns        0.347 ns   1941062305