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 Mar 19 18:39:42 UTC 2026 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

-3.46% average profit over 11 trades.

Time Token Open Close Hours Profit
2026-03-14 09:00:00 Kraken-ZEC-EUR 181.17 186.73 16 3.1%
2026-03-03 22:00:00 Coinbase-LINK-GBP 6.56 6.90 11 5.2%
2026-02-26 08:00:00 Binance-BCH-EUR 424.10 397.83 29 -6.2%
2026-02-19 13:00:00 Kraken-XMR-EUR 281.05 272.94 67 -2.9%
2026-02-19 04:00:00 Coinbase-AAVE-GBP 91.75 85.70 44 -6.6%
2026-02-09 01:00:00 Coinbase-ETC-EUR 7.26 6.80 54 -6.3%
2026-02-09 01:00:00 Coinbase-LTC-GBP 40.08 38.26 67 -4.5%
2026-01-16 12:00:00 Kraken-ZEC-EUR 354.94 332.44 59 -6.3%
2026-01-15 12:00:00 Kraken-LTC-GBP 56.34 55.93 67 -0.7%
2026-01-07 02:00:00 Kraken-DASH-EUR 36.99 34.74 26 -6.1%
2026-01-07 02:00:00 Kraken-INJ-EUR 4.64 4.34 34 -6.6%

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                53064 ns        53064 ns        13196
BM_is_entry2               40236 ns        40176 ns        17437
BM_to_exit                   222 ns          222 ns      3164306
BM_to_exit2                  221 ns          221 ns      3142066
BM_to_vwap                  7582 ns         7582 ns        92890
BM_to_vwap2                 7566 ns         7566 ns        92346
BM_is_recent_dip2            889 ns          889 ns       787957
BM_to_atr                  60304 ns        60305 ns        11617
BM_to_atr2                  2434 ns         2434 ns       288274
BM_to_atr3                  2560 ns         2560 ns       273027
BM_to_average_func         0.331 ns        0.331 ns   2122481307
BM_to_average_func2        0.336 ns        0.336 ns   2082502941
BM_to_average_volume       61430 ns        61429 ns        11339
BM_to_average_volume2       1920 ns         1920 ns       364744
BM_to_size                 0.511 ns        0.511 ns   1376080690
BM_to_first                0.334 ns        0.334 ns   2059502263
BM_to_last                 0.345 ns        0.345 ns   2137405814
BM_to_sum                  0.336 ns        0.336 ns   2064145930
BM_to_sum2                 0.355 ns        0.355 ns   2065435164
BM_to_spot                 0.350 ns        0.350 ns   2006969172
BM_identity                  168 ns          168 ns      4190002
BM_identity2                 169 ns          169 ns      4081705
BM_to_profit               0.341 ns        0.341 ns   2040583295
BM_to_time                 0.345 ns        0.345 ns   1987851778
BM_to_open                 0.358 ns        0.358 ns   1995206488
BM_to_high                 0.356 ns        0.356 ns   2049503713
BM_to_low                  0.335 ns        0.335 ns   2032828844
BM_to_close                0.343 ns        0.343 ns   2009512516
BM_to_volume               0.357 ns        0.357 ns   2075061674