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 Sep 10 17:40:18 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                52864 ns        52862 ns        13164
BM_is_entry2               40393 ns        40363 ns        17481
BM_to_exit                   221 ns          221 ns      3196025
BM_to_exit2                  219 ns          219 ns      3190586
BM_to_vwap                  7571 ns         7570 ns        92709
BM_to_vwap2                 7583 ns         7583 ns        92625
BM_is_recent_dip2            885 ns          885 ns       789706
BM_to_atr                  60018 ns        60017 ns        11671
BM_to_atr2                  2374 ns         2374 ns       291807
BM_to_atr3                  2513 ns         2513 ns       277444
BM_to_average_func         0.321 ns        0.321 ns   2190832249
BM_to_average_func2        0.322 ns        0.322 ns   2211715877
BM_to_average_volume       61610 ns        61440 ns        11444
BM_to_average_volume2       1890 ns         1890 ns       373838
BM_to_size                 0.506 ns        0.506 ns   1378172477
BM_to_first                0.326 ns        0.326 ns   2152951361
BM_to_last                 0.324 ns        0.324 ns   2162182251
BM_to_sum                  0.327 ns        0.327 ns   2187389674
BM_to_sum2                 0.336 ns        0.336 ns   2126718492
BM_to_spot                 0.327 ns        0.327 ns   2203148149
BM_identity                  160 ns          160 ns      4359459
BM_identity2                 161 ns          161 ns      4369156
BM_to_profit               0.326 ns        0.325 ns   2126818964
BM_to_time                 0.334 ns        0.334 ns   2155723743
BM_to_open                 0.347 ns        0.347 ns   2089268242
BM_to_high                 0.335 ns        0.335 ns   2110122621
BM_to_low                  0.332 ns        0.332 ns   2098672216
BM_to_close                0.336 ns        0.336 ns   2046446201
BM_to_volume               0.330 ns        0.330 ns   2101578437