Crypto backtesting
Loading...
Searching...
No Matches
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 22 17:38:20 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

Benchmarks


----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_is_entry                53118 ns        52920 ns        13253
BM_is_entry2               40417 ns        40306 ns        17527
BM_to_exit                   230 ns          229 ns      3184803
BM_to_exit2                  220 ns          220 ns      3178078
BM_to_vwap                  7530 ns         7529 ns        92680
BM_to_vwap2                 7536 ns         7536 ns        93038
BM_is_recent_dip2            890 ns          890 ns       788075
BM_to_atr                  60057 ns        60057 ns        11538
BM_to_atr2                  2396 ns         2396 ns       291791
BM_to_atr3                  2558 ns         2557 ns       275714
BM_to_average_func         0.320 ns        0.320 ns   2149311418
BM_to_average_func2        0.314 ns        0.314 ns   2137061645
BM_to_average_volume       62189 ns        61484 ns        11323
BM_to_average_volume2       1885 ns         1885 ns       370958
BM_to_size                 0.508 ns        0.508 ns   1382055093
BM_to_first                0.315 ns        0.315 ns   2222828603
BM_to_last                 0.327 ns        0.327 ns   2151369286
BM_to_sum                  0.316 ns        0.316 ns   2193018532
BM_to_sum2                 0.314 ns        0.314 ns   2217957414
BM_to_spot                 0.313 ns        0.313 ns   2242057829
BM_identity                  162 ns          162 ns      4331374
BM_identity2                 161 ns          161 ns      4316795
BM_to_profit               0.324 ns        0.323 ns   2244585721
BM_to_time                 0.320 ns        0.319 ns   2191107865
BM_to_open                 0.317 ns        0.317 ns   2247215698
BM_to_high                 0.315 ns        0.315 ns   2214274390
BM_to_low                  0.318 ns        0.318 ns   2220275295
BM_to_close                0.323 ns        0.323 ns   2230476984
BM_to_volume               0.323 ns        0.322 ns   2131779975