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 3 17:44:57 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                53104 ns        53023 ns        13229
BM_is_entry2               40446 ns        40382 ns        17418
BM_to_exit                   229 ns          229 ns      3141472
BM_to_exit2                  240 ns          239 ns      2962916
BM_to_vwap                  7636 ns         7636 ns        91680
BM_to_vwap2                 7643 ns         7643 ns        92085
BM_is_recent_dip2            895 ns          895 ns       777909
BM_to_atr                  60961 ns        60960 ns        11547
BM_to_atr2                  2445 ns         2438 ns       285547
BM_to_atr3                  2595 ns         2595 ns       270648
BM_to_average_func         0.339 ns        0.339 ns   2107519560
BM_to_average_func2        0.345 ns        0.345 ns   2083707297
BM_to_average_volume       62399 ns        62394 ns        11239
BM_to_average_volume2       1906 ns         1906 ns       370144
BM_to_size                 0.509 ns        0.509 ns   1376111475
BM_to_first                0.335 ns        0.335 ns   2085649037
BM_to_last                 0.338 ns        0.337 ns   2110773763
BM_to_sum                  0.337 ns        0.337 ns   2129612688
BM_to_sum2                 0.339 ns        0.338 ns   2122131075
BM_to_spot                 0.329 ns        0.329 ns   2130767607
BM_identity                  165 ns          165 ns      4356024
BM_identity2                 162 ns          162 ns      4365190
BM_to_profit               0.348 ns        0.348 ns   2075991792
BM_to_time                 0.331 ns        0.331 ns   2031574068
BM_to_open                 0.340 ns        0.340 ns   2083396220
BM_to_high                 0.352 ns        0.352 ns   2064807743
BM_to_low                  0.334 ns        0.334 ns   2007419716
BM_to_close                0.338 ns        0.338 ns   2058331861
BM_to_volume               0.344 ns        0.344 ns   2082755567