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 4 18:38:52 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.07% average profit over 22 trades.

Time Token Open Close Hours Profit
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 Coinbase-SOL-EUR 161.59 167.18 14 3.5%
2025-10-21 01:00:00 Binance-SOL-EUR 161.59 167.12 14 3.4%
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                53586 ns        53585 ns        13241
BM_is_entry2               41338 ns        41337 ns        17457
BM_to_exit                   227 ns          227 ns      3049537
BM_to_exit2                  221 ns          221 ns      3182003
BM_to_vwap                  7651 ns         7651 ns        91125
BM_to_vwap2                 7643 ns         7643 ns        92092
BM_is_recent_dip2            889 ns          889 ns       784301
BM_to_atr                  60959 ns        60941 ns        11574
BM_to_atr2                  2442 ns         2442 ns       287742
BM_to_atr3                  2600 ns         2600 ns       264925
BM_to_average_func         0.367 ns        0.367 ns   2041952920
BM_to_average_func2        0.345 ns        0.345 ns   2000535538
BM_to_average_volume       62540 ns        62538 ns        10686
BM_to_average_volume2       1909 ns         1909 ns       368046
BM_to_size                 0.513 ns        0.513 ns   1376430554
BM_to_first                0.348 ns        0.347 ns   2094826800
BM_to_last                 0.348 ns        0.348 ns   2118834372
BM_to_sum                  0.353 ns        0.353 ns   2103379390
BM_to_sum2                 0.364 ns        0.364 ns   2066140822
BM_to_spot                 0.341 ns        0.341 ns   2022668988
BM_identity                  167 ns          167 ns      4178376
BM_identity2                 167 ns          167 ns      4341893
BM_to_profit               0.363 ns        0.363 ns   1933431874
BM_to_time                 0.367 ns        0.367 ns   2020232169
BM_to_open                 0.350 ns        0.350 ns   1971283053
BM_to_high                 0.331 ns        0.331 ns   2086309964
BM_to_low                  0.340 ns        0.340 ns   2037824889
BM_to_close                0.361 ns        0.361 ns   1891294759
BM_to_volume               0.336 ns        0.336 ns   1953209832