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 Oct 16 17:39:00 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.19% average profit over 19 trades.

Time Token Open Close Hours Profit
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 4040.00 50 -3.7%
2025-10-08 03:00:00 Coinbase-LINK-GBP 16.34 16.84 20 3.1%
2025-08-19 12:00:00 Kraken-LINK-GBP 18.24 19.13 27 4.8%
2025-08-19 12:00:00 Coinbase-LINK-EUR 21.09 22.09 27 4.8%
2025-08-18 15:00:00 Kraken-AVAX-EUR 20.22 19.88 67 -1.7%
2025-08-18 15:00:00 Binance-AVAX-EUR 20.27 19.85 67 -2.1%
2025-08-18 15:00:00 Coinbase-AVAX-EUR 20.25 19.84 67 -2.0%
2025-08-15 06:00:00 Kraken-GNO-EUR 126.24 118.42 13 -6.2%
2025-08-12 06:00:00 Coinbase-LINK-GBP 16.00 16.63 7 3.9%
2025-08-11 20:00:00 Kraken-LINK-EUR 18.41 19.26 17 4.6%
2025-08-06 12:00:00 Coinbase-SOL-GBP 123.11 126.81 19 3.0%
2025-08-06 12:00:00 Coinbase-SOL-EUR 141.24 146.39 22 3.6%
2025-08-06 12:00:00 Kraken-SOL-EUR 141.27 146.43 22 3.7%
2025-08-01 04:00:00 Kraken-KP3R-EUR 5.15 5.31 1 3.1%
2025-07-30 09:00:00 Kraken-RPL-EUR 6.32 6.52 8 3.1%
2025-07-29 11:00:00 Coinbase-UNI-EUR 8.89 8.34 57 -6.2%
2025-07-29 11:00:00 Kraken-UNI-EUR 8.89 8.34 57 -6.2%
2025-07-29 10:00:00 Coinbase-AVAX-EUR 21.43 20.03 33 -6.5%

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                52799 ns        52798 ns        13298
BM_is_entry2               40172 ns        40171 ns        17356
BM_to_exit                   220 ns          220 ns      3195872
BM_to_exit2                  220 ns          220 ns      3134503
BM_to_vwap                  7543 ns         7543 ns        92929
BM_to_vwap2                 7542 ns         7540 ns        93192
BM_is_recent_dip2            893 ns          889 ns       782753
BM_to_atr                  60369 ns        60367 ns        11573
BM_to_atr2                  2406 ns         2406 ns       293592
BM_to_atr3                  2534 ns         2534 ns       274590
BM_to_average_func         0.333 ns        0.333 ns   2128362367
BM_to_average_func2        0.334 ns        0.334 ns   2101463806
BM_to_average_volume       61223 ns        61221 ns        11442
BM_to_average_volume2       1874 ns         1874 ns       372842
BM_to_size                 0.510 ns        0.510 ns   1365705736
BM_to_first                0.329 ns        0.329 ns   2096451090
BM_to_last                 0.333 ns        0.333 ns   2114270816
BM_to_sum                  0.333 ns        0.333 ns   2088429312
BM_to_sum2                 0.331 ns        0.331 ns   2071313691
BM_to_spot                 0.336 ns        0.336 ns   2067964003
BM_identity                  162 ns          162 ns      4320476
BM_identity2                 162 ns          162 ns      4360278
BM_to_profit               0.343 ns        0.343 ns   2122361965
BM_to_time                 0.334 ns        0.334 ns   2113525964
BM_to_open                 0.335 ns        0.335 ns   2110880283
BM_to_high                 0.333 ns        0.333 ns   2131778287
BM_to_low                  0.337 ns        0.337 ns   2048671698
BM_to_close                0.341 ns        0.341 ns   2137856866
BM_to_volume               0.345 ns        0.345 ns   2125351830