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 Tue Feb 27 15:31:11 UTC 2024 by a Ubuntu Noble Numbat (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.58% average profit over 64 trades.

Time Token Open Close Hours Profit
2024-02-27 09:00:00 Kraken-NMR-EUR 29.35 29.20 6 -0.5%
2024-02-26 21:00:00 Kraken-FIL-GBP 6.37 6.21 18 -2.7%
2024-02-26 19:00:00 Coinbase-FIL-EUR 7.31 7.59 10 3.8%
2024-02-26 19:00:00 Kraken-FIL-EUR 7.32 7.58 10 3.5%
2024-02-15 14:00:00 Coinbase-RNDR-EUR 4.61 4.92 9 6.7%
2024-02-14 01:00:00 Binance-AVAX-EUR 36.69 38.30 8 4.4%
2024-02-09 04:00:00 Binance-LINK-EUR 16.91 17.64 44 4.3%
2024-02-04 15:00:00 Coinbase-ICP-GBP 10.05 10.36 2 3.1%
2024-01-31 19:00:00 Coinbase-SOL-EUR 93.25 86.99 7 -6.7%
2024-01-31 19:00:00 Binance-SOL-EUR 93.30 87.01 7 -6.7%
2024-01-31 19:00:00 Coinbase-SOL-GBP 79.44 74.17 7 -6.6%
2024-01-31 19:00:00 Kraken-AVAX-EUR 32.39 30.35 6 -6.3%
2024-01-31 09:00:00 Binance-EGLD-EUR 51.36 48.23 16 -6.1%
2024-01-31 09:00:00 Binance-SOL-EUR 92.85 87.01 17 -6.3%
2024-01-30 12:00:00 Kraken-INJ-EUR 34.16 32.11 21 -6.0%
2024-01-29 07:00:00 Binance-ICP-EUR 11.31 11.65 10 3.0%
2024-01-21 15:00:00 Coinbase-LINK-GBP 12.31 11.55 31 -6.1%
2024-01-18 13:00:00 Coinbase-LINK-EUR 14.04 14.70 34 4.7%
2024-01-18 12:00:00 Binance-LINK-EUR 14.19 13.32 7 -6.2%
2024-01-18 12:00:00 Kraken-LINK-EUR 14.17 13.31 7 -6.0%
2024-01-18 10:00:00 Binance-EGLD-EUR 49.01 45.73 17 -6.7%
2024-01-17 16:00:00 Kraken-AVAX-EUR 32.90 30.76 27 -6.5%
2024-01-17 16:00:00 Coinbase-AVAX-EUR 32.90 30.78 27 -6.4%
2024-01-17 03:00:00 Coinbase-AAVE-GBP 81.89 76.87 39 -6.1%
2024-01-15 08:00:00 Kraken-ATOM-EUR 9.16 9.48 19 3.5%
2024-01-15 08:00:00 Coinbase-SOL-GBP 74.90 77.15 25 3.0%
2024-01-10 22:00:00 Kraken-TBTC-EUR 42466.67 44066.67 17 3.8%
2024-01-10 21:00:00 Coinbase-BTC-GBP 36050.08 37748.15 17 4.7%
2024-01-10 21:00:00 Coinbase-BTC-EUR 41888.29 43146.72 16 3.0%
2024-01-10 21:00:00 Kraken-BTC-EUR 41840.87 43110.53 16 3.0%
2024-01-10 21:00:00 Binance-BTC-EUR 41898.30 43768.65 17 4.5%
2024-01-06 15:00:00 Binance-ATOM-EUR 9.10 8.50 34 -6.6%
2024-01-06 15:00:00 Coinbase-ATOM-EUR 9.09 8.50 34 -6.6%
2024-01-06 01:00:00 Kraken-SOL-EUR 90.34 84.89 26 -6.0%
2024-01-05 15:00:00 Coinbase-ENS-EUR 12.71 11.84 15 -6.9%
2024-01-03 20:00:00 Coinbase-ENS-EUR 10.77 11.30 1 4.9%
2024-01-03 20:00:00 Kraken-ENS-EUR 10.73 11.24 1 4.7%
2024-01-03 12:00:00 Kraken-ORCA-EUR 5.47 5.08 6 -7.2%
2024-01-03 08:00:00 Coinbase-SOL-EUR 98.60 89.05 4 -9.7%
2024-01-02 23:00:00 Kraken-KSM-EUR 43.56 45.03 3 3.4%
2024-01-01 14:00:00 Binance-DOT-EUR 7.49 7.77 5 3.7%
2023-12-31 08:00:00 Kraken-ALCX-EUR 24.50 25.93 13 5.9%
2023-12-29 16:00:00 Kraken-AAVE-GBP 87.08 90.71 13 4.2%
2023-12-29 16:00:00 Kraken-AAVE-EUR 100.58 104.74 13 4.1%
2023-12-28 23:00:00 Kraken-EGLD-EUR 62.69 64.73 22 3.2%
2023-12-27 18:00:00 Kraken-FARM-EUR 45.59 42.59 9 -6.6%
2023-12-27 11:00:00 Kraken-ATOM-GBP 9.21 9.50 14 3.1%
2023-12-27 11:00:00 Coinbase-ATOM-EUR 10.58 10.94 14 3.3%
2023-12-26 17:00:00 Kraken-FIL-GBP 4.40 4.56 22 3.7%
2023-12-26 17:00:00 Kraken-MSOL-EUR 120.52 113.24 2 -6.0%
2023-12-25 19:00:00 Binance-LINK-EUR 14.07 14.70 45 4.5%
2023-12-25 18:00:00 Coinbase-ICP-EUR 8.60 8.06 24 -6.3%
2023-12-25 12:00:00 Kraken-LPT-EUR 8.18 7.57 30 -7.5%
2023-12-25 08:00:00 Kraken-GNO-EUR 178.51 182.09 67 2.0%
2023-12-25 08:00:00 Coinbase-ATOM-EUR 10.34 10.74 7 3.9%
2023-12-25 08:00:00 Kraken-ATOM-EUR 10.33 10.64 6 3.0%
2023-12-23 23:00:00 Kraken-FXS-EUR 8.04 7.58 67 -5.8%
2023-12-23 18:00:00 Kraken-GNO-EUR 177.74 193.09 9 8.6%
2023-12-23 12:00:00 Coinbase-ICP-GBP 7.19 7.57 12 5.2%
2023-12-23 12:00:00 Kraken-FXS-EUR 8.02 7.64 67 -4.8%
2023-12-22 00:00:00 Kraken-QNT-EUR 99.02 102.84 16 3.9%
2023-12-20 02:00:00 Binance-LINK-EUR 12.83 13.28 11 3.5%
2023-12-18 21:00:00 Kraken-LPT-EUR 6.61 6.85 6 3.6%
2023-12-17 22:00:00 Binance-AVAX-EUR 37.81 35.39 11 -6.4%

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                55266 ns        55201 ns        12706
BM_is_entry2               41834 ns        41834 ns        16650
BM_to_exit                   215 ns          215 ns      3235845
BM_to_exit2                  237 ns          237 ns      2959604
BM_to_vwap                  7529 ns         7528 ns        92452
BM_to_vwap2                 7529 ns         7528 ns        93293
BM_is_recent_dip2            801 ns          801 ns       872373
BM_to_atr                  64022 ns        63963 ns        10989
BM_to_atr2                  2422 ns         2421 ns       284249
BM_to_atr3                  2399 ns         2398 ns       292838
BM_to_average_func         0.330 ns        0.330 ns   1000000000
BM_to_average_func2        0.335 ns        0.335 ns   1000000000
BM_to_average_volume       59093 ns        59092 ns        11646
BM_to_average_volume2       1879 ns         1879 ns       372245
BM_to_size                 0.626 ns        0.626 ns   1000000000
BM_to_first                0.330 ns        0.330 ns   1000000000
BM_to_last                 0.630 ns        0.629 ns   1000000000
BM_to_sum                  0.628 ns        0.628 ns   1000000000
BM_to_sum2                 0.334 ns        0.334 ns   1000000000
BM_to_spot                 0.330 ns        0.330 ns   1000000000
BM_identity                  159 ns          159 ns      4429260
BM_identity2                 159 ns          159 ns      4431726
BM_to_profit               0.329 ns        0.329 ns   1000000000
BM_to_time                 0.631 ns        0.631 ns   1000000000
BM_to_open                 0.329 ns        0.329 ns   1000000000
BM_to_high                 0.336 ns        0.336 ns   1000000000
BM_to_low                  0.336 ns        0.336 ns   1000000000
BM_to_close                0.335 ns        0.335 ns   1000000000
BM_to_volume               0.630 ns        0.629 ns   1000000000