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 Apr 9 17:38:54 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

-2.17% average profit over 8 trades.

Time Token Open Close Hours Profit
2026-04-09 12:00:00 Coinbase-AAVE-EUR 77.02 77.75 5 0.9%
2026-03-14 09:00:00 Kraken-ZEC-EUR 181.17 186.73 16 3.1%
2026-03-03 22:00:00 Coinbase-LINK-GBP 6.56 6.90 11 5.2%
2026-02-26 08:00:00 Binance-BCH-EUR 424.10 397.83 29 -6.2%
2026-02-19 13:00:00 Kraken-XMR-EUR 281.05 272.94 67 -2.9%
2026-02-19 04:00:00 Coinbase-AAVE-GBP 91.75 85.70 44 -6.6%
2026-02-09 01:00:00 Coinbase-ETC-EUR 7.26 6.80 54 -6.3%
2026-02-09 01:00:00 Coinbase-LTC-GBP 40.08 38.26 67 -4.5%

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                53120 ns        53115 ns        13189
BM_is_entry2               40579 ns        40578 ns        16882
BM_to_exit                   223 ns          223 ns      3171515
BM_to_exit2                  222 ns          222 ns      3171960
BM_to_vwap                  7531 ns         7531 ns        92749
BM_to_vwap2                 7569 ns         7570 ns        92831
BM_is_recent_dip2            888 ns          888 ns       785850
BM_to_atr                  60912 ns        60912 ns        11677
BM_to_atr2                  2420 ns         2417 ns       289602
BM_to_atr3                  2550 ns         2550 ns       266352
BM_to_average_func         0.328 ns        0.328 ns   2193207342
BM_to_average_func2        0.317 ns        0.317 ns   2179271676
BM_to_average_volume       62035 ns        62031 ns        11354
BM_to_average_volume2       1894 ns         1894 ns       368208
BM_to_size                 0.508 ns        0.508 ns   1370742837
BM_to_first                0.323 ns        0.323 ns   2157095330
BM_to_last                 0.322 ns        0.322 ns   2137562120
BM_to_sum                  0.330 ns        0.330 ns   2140975577
BM_to_sum2                 0.323 ns        0.323 ns   2190943890
BM_to_spot                 0.327 ns        0.327 ns   2216125766
BM_identity                  169 ns          169 ns      4140704
BM_identity2                 170 ns          170 ns      4101245
BM_to_profit               0.327 ns        0.327 ns   2113373587
BM_to_time                 0.330 ns        0.330 ns   2151914708
BM_to_open                 0.328 ns        0.328 ns   2155008055
BM_to_high                 0.329 ns        0.329 ns   2108717612
BM_to_low                  0.329 ns        0.329 ns   2128572829
BM_to_close                0.327 ns        0.327 ns   2154069494
BM_to_volume               0.335 ns        0.335 ns   2156696298