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 Jul 3 17:36:24 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.30% average profit over 46 trades.

Time Token Open Close Hours Profit
2025-06-30 20:00:00 Kraken-LPT-EUR 5.35 5.36 67 0.2%
2025-06-18 01:00:00 Coinbase-UNI-EUR 6.48 6.68 4 3.1%
2025-06-18 01:00:00 Coinbase-LINK-EUR 11.38 10.98 67 -3.5%
2025-06-11 18:00:00 Kraken-INJ-EUR 11.90 11.16 16 -6.2%
2025-06-02 18:00:00 Kraken-INJ-EUR 10.39 10.90 5 4.9%
2025-05-31 18:00:00 Kraken-MLN-EUR 7.25 7.55 2 4.1%
2025-05-30 09:00:00 Coinbase-UNI-GBP 4.84 4.48 16 -7.4%
2025-05-30 09:00:00 Coinbase-ETH-EUR 2305.12 2197.66 67 -4.7%
2025-05-30 09:00:00 Kraken-ETH-EUR 2305.22 2197.32 67 -4.7%
2025-05-24 09:00:00 Kraken-SOL-GBP 129.39 128.02 67 -1.1%
2025-05-24 08:00:00 Kraken-BCH-EUR 376.78 361.94 67 -3.9%
2025-05-24 08:00:00 Kraken-APT-EUR 4.76 4.46 31 -6.3%
2025-05-23 20:00:00 Kraken-LTC-GBP 72.61 71.50 67 -1.5%
2025-05-19 18:00:00 Kraken-KSM-EUR 16.33 16.85 8 3.2%
2025-05-19 15:00:00 Kraken-LINK-EUR 13.73 14.17 10 3.2%
2025-05-17 13:00:00 Kraken-EUL-EUR 8.60 8.63 67 0.3%
2025-05-17 10:00:00 Kraken-ETH-EUR 2221.93 2295.65 29 3.3%
2025-05-15 18:00:00 Kraken-QNT-EUR 87.59 82.15 30 -6.2%
2025-05-15 01:00:00 Coinbase-SOL-GBP 133.01 124.70 49 -6.2%
2025-05-15 01:00:00 Coinbase-SOL-EUR 157.75 148.24 49 -6.0%
2025-05-13 12:00:00 Kraken-LINK-GBP 12.62 13.17 7 4.4%
2025-05-13 12:00:00 Kraken-LINK-EUR 14.99 15.67 7 4.5%
2025-05-13 12:00:00 Coinbase-LINK-GBP 12.61 13.18 7 4.6%
2025-05-13 12:00:00 Coinbase-LINK-EUR 15.00 15.66 7 4.4%
2025-05-13 12:00:00 Coinbase-AVAX-EUR 22.08 23.01 7 4.2%
2025-05-13 12:00:00 Kraken-QNT-EUR 88.28 83.88 67 -5.0%
2025-05-13 12:00:00 Coinbase-AAVE-EUR 196.91 203.47 4 3.3%
2025-05-13 12:00:00 Binance-LINK-EUR 15.00 15.45 6 3.0%
2025-05-13 12:00:00 Kraken-ICP-EUR 5.08 5.23 6 3.1%
2025-05-13 12:00:00 Binance-AVAX-EUR 22.10 23.02 7 4.1%
2025-05-13 11:00:00 Binance-DOT-EUR 4.52 4.66 13 3.0%
2025-05-13 11:00:00 Kraken-KSM-EUR 19.18 19.89 7 3.7%
2025-05-13 11:00:00 Kraken-DOT-EUR 4.52 4.67 14 3.3%
2025-05-13 11:00:00 Kraken-AVAX-EUR 22.09 23.02 8 4.2%
2025-05-13 11:00:00 Coinbase-DOT-EUR 4.52 4.66 13 3.0%
2025-05-12 00:00:00 Kraken-BCH-EUR 364.06 361.12 67 -0.8%
2025-05-12 00:00:00 Coinbase-LTC-GBP 75.69 77.98 11 3.0%
2025-05-05 21:00:00 Kraken-AAVE-EUR 155.94 146.11 15 -6.3%
2025-05-05 01:00:00 Coinbase-AAVE-GBP 129.99 134.05 5 3.1%
2025-04-30 07:00:00 Kraken-LINK-GBP 10.88 11.22 28 3.2%
2025-04-28 10:00:00 Coinbase-ENS-EUR 16.21 16.77 64 3.5%
2025-04-28 00:00:00 Coinbase-AAVE-GBP 125.03 128.80 6 3.0%
2025-04-26 21:00:00 Kraken-AVAX-EUR 19.55 19.36 67 -1.0%
2025-04-15 06:00:00 Kraken-ETH-GBP 1241.41 1191.77 67 -4.0%
2025-04-14 07:00:00 Kraken-INJ-EUR 7.22 6.74 49 -6.6%
2025-04-14 07:00:00 Binance-LINK-EUR 11.09 11.54 4 4.0%

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                52968 ns        52886 ns        13000
BM_is_entry2               40363 ns        40303 ns        17419
BM_to_exit                   222 ns          222 ns      3168081
BM_to_exit2                  222 ns          222 ns      3153870
BM_to_vwap                  7600 ns         7600 ns        91645
BM_to_vwap2                 7553 ns         7553 ns        92457
BM_is_recent_dip2            889 ns          889 ns       786366
BM_to_atr                  60371 ns        60370 ns        11651
BM_to_atr2                  2609 ns         2609 ns       270371
BM_to_atr3                  2716 ns         2712 ns       256654
BM_to_average_func         0.343 ns        0.343 ns   2004522529
BM_to_average_func2        0.341 ns        0.341 ns   2065983145
BM_to_average_volume       61067 ns        61067 ns        11343
BM_to_average_volume2       1958 ns         1958 ns       357292
BM_to_size                 0.514 ns        0.513 ns   1380126700
BM_to_first                0.358 ns        0.358 ns   1969094638
BM_to_last                 0.345 ns        0.345 ns   1977262023
BM_to_sum                  0.338 ns        0.338 ns   2052546546
BM_to_sum2                 0.335 ns        0.335 ns   2045843800
BM_to_spot                 0.334 ns        0.334 ns   2090058931
BM_identity                  161 ns          161 ns      4355137
BM_identity2                 161 ns          161 ns      4389710
BM_to_profit               0.337 ns        0.337 ns   2097748449
BM_to_time                 0.336 ns        0.336 ns   2058127949
BM_to_open                 0.348 ns        0.348 ns   2125729651
BM_to_high                 0.331 ns        0.331 ns   2018345486
BM_to_low                  0.331 ns        0.331 ns   1896626435
BM_to_close                0.337 ns        0.337 ns   2077283511
BM_to_volume               0.337 ns        0.337 ns   2110393057