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 Dec 18 18:39:23 UTC 2025 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

0.53% average profit over 26 trades.

Time Token Open Close Hours Profit
2025-12-11 09:00:00 Kraken-ZEC-EUR 355.01 377.49 3 6.3%
2025-12-10 22:00:00 Coinbase-UNI-EUR 4.85 4.54 18 -6.5%
2025-12-09 14:00:00 Binance-SOL-EUR 113.74 120.81 2 6.2%
2025-12-09 14:00:00 Coinbase-SOL-EUR 113.74 120.71 2 6.1%
2025-11-19 14:00:00 Coinbase-ETH-GBP 2326.37 2171.41 27 -6.7%
2025-11-19 14:00:00 Kraken-ETH-GBP 2326.54 2172.84 27 -6.6%
2025-11-19 13:00:00 Coinbase-BCH-EUR 425.82 439.77 16 3.3%
2025-11-18 14:00:00 Coinbase-UNI-EUR 6.35 6.60 2 4.0%
2025-11-18 14:00:00 Coinbase-UNI-GBP 5.60 5.78 2 3.3%
2025-11-18 04:00:00 Coinbase-UNI-EUR 6.41 6.60 12 3.1%
2025-11-17 02:00:00 Kraken-XMR-EUR 347.87 308.84 52 -11.2%
2025-11-14 21:00:00 Kraken-QNT-EUR 73.49 71.45 67 -2.8%
2025-11-11 01:00:00 Kraken-ALCX-EUR 9.02 8.42 10 -6.7%
2025-11-09 13:00:00 Kraken-ALCX-EUR 8.84 9.42 7 6.6%
2025-11-05 10:00:00 Kraken-MLN-EUR 5.37 5.57 7 3.7%
2025-10-28 12:00:00 Kraken-MLN-EUR 6.64 6.22 6 -6.4%
2025-10-21 13:00:00 Binance-SOL-EUR 160.10 167.12 2 4.4%
2025-10-21 13:00:00 Kraken-LINK-EUR 15.58 16.15 2 3.6%
2025-10-21 13:00:00 Coinbase-AAVE-GBP 166.03 174.95 2 5.4%
2025-10-21 13:00:00 Coinbase-AAVE-EUR 191.28 201.24 2 5.2%
2025-10-21 01:00:00 Binance-SOL-EUR 161.59 167.12 14 3.4%
2025-10-21 01:00:00 Coinbase-SOL-EUR 161.59 167.18 14 3.5%
2025-10-19 09:00:00 Coinbase-LINK-EUR 14.38 14.95 5 3.9%
2025-10-14 21:00:00 Kraken-LINK-EUR 16.34 15.20 43 -6.9%
2025-10-14 15:00:00 Kraken-YFI-EUR 4194.00 3879.67 64 -7.5%
2025-10-08 03:00:00 Coinbase-LINK-GBP 16.34 16.84 20 3.1%

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                53753 ns        53753 ns        13145
BM_is_entry2               41845 ns        41844 ns        17345
BM_to_exit                   231 ns          231 ns      2916874
BM_to_exit2                  239 ns          239 ns      2964157
BM_to_vwap                  7812 ns         7812 ns        87792
BM_to_vwap2                 7794 ns         7794 ns        86726
BM_is_recent_dip2            913 ns          913 ns       757469
BM_to_atr                  61374 ns        61373 ns        11330
BM_to_atr2                  2433 ns         2433 ns       285525
BM_to_atr3                  2599 ns         2599 ns       270315
BM_to_average_func         0.373 ns        0.373 ns   1944247395
BM_to_average_func2        0.347 ns        0.347 ns   1740229200
BM_to_average_volume       63103 ns        63102 ns        11402
BM_to_average_volume2       1947 ns         1944 ns       370651
BM_to_size                 0.526 ns        0.525 ns   1352502258
BM_to_first                0.334 ns        0.334 ns   1964377612
BM_to_last                 0.346 ns        0.346 ns   2136995758
BM_to_sum                  0.356 ns        0.356 ns   1899757705
BM_to_sum2                 0.346 ns        0.345 ns   2030828081
BM_to_spot                 0.363 ns        0.362 ns   2074907314
BM_identity                  170 ns          169 ns      4096127
BM_identity2                 169 ns          169 ns      4206363
BM_to_profit               0.349 ns        0.349 ns   2070141309
BM_to_time                 0.361 ns        0.361 ns   2070864645
BM_to_open                 0.373 ns        0.372 ns   1908143972
BM_to_high                 0.355 ns        0.355 ns   1948867529
BM_to_low                  0.361 ns        0.361 ns   2031822049
BM_to_close                0.360 ns        0.360 ns   2035141012
BM_to_volume               0.343 ns        0.343 ns   2023379795