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 May 21 17:39:21 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

3.73% average profit over 5 trades.

Time Token Open Close Hours Profit
2026-04-23 17:00:00 Coinbase-AAVE-EUR 79.20 81.78 41 3.3%
2026-04-17 12:00:00 Kraken-KSM-EUR 4.33 4.47 2 3.3%
2026-04-09 12:00:00 Coinbase-AAVE-EUR 77.02 79.98 31 3.8%
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%

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                54222 ns        54220 ns        12892
BM_is_entry2               41656 ns        41655 ns        16813
BM_to_exit                   235 ns          235 ns      2890853
BM_to_exit2                  235 ns          234 ns      2977445
BM_to_vwap                  5896 ns         5896 ns       121449
BM_to_vwap2                 5904 ns         5904 ns       118894
BM_is_recent_dip2            979 ns          979 ns       715994
BM_to_atr                  67337 ns        67337 ns        10378
BM_to_atr2                  3096 ns         3096 ns       227502
BM_to_atr3                  3090 ns         3090 ns       224187
BM_to_average_func         0.355 ns        0.355 ns   1952602859
BM_to_average_func2        0.359 ns        0.359 ns   1945735478
BM_to_average_volume       61381 ns        61380 ns        11414
BM_to_average_volume2       1703 ns         1703 ns       411006
BM_to_size                 0.531 ns        0.531 ns   1322008030
BM_to_first                0.358 ns        0.358 ns   1959934361
BM_to_last                 0.368 ns        0.368 ns   1951504440
BM_to_sum                  0.360 ns        0.360 ns   1956916542
BM_to_sum2                 0.359 ns        0.359 ns   1955562163
BM_to_spot                 0.367 ns        0.367 ns   1929125330
BM_identity                  112 ns          112 ns      6300109
BM_identity2                 112 ns          112 ns      6305388
BM_to_profit               0.354 ns        0.354 ns   1976643791
BM_to_time                 0.359 ns        0.359 ns   1954021816
BM_to_open                 0.358 ns        0.358 ns   1966986525
BM_to_high                 0.360 ns        0.360 ns   1946352724
BM_to_low                  0.357 ns        0.357 ns   1925137243
BM_to_close                0.357 ns        0.357 ns   1974027072
BM_to_volume               0.362 ns        0.362 ns   1943551048