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 Jul 23 17:38:35 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                26505 ns        26502 ns        27709
BM_is_entry2               20832 ns        20822 ns        33291
BM_to_exit                   143 ns          143 ns      4590986
BM_to_exit2                  145 ns          145 ns      4737180
BM_to_vwap                  6012 ns         6008 ns       117621
BM_to_vwap2                 6055 ns         6055 ns       117638
BM_is_recent_dip2            703 ns          702 ns       990329
BM_to_atr                  30814 ns        30796 ns        23018
BM_to_atr2                  1423 ns         1422 ns       484824
BM_to_atr3                  1553 ns         1552 ns       447261
BM_to_average_func         0.249 ns        0.249 ns   2822113597
BM_to_average_func2        0.249 ns        0.249 ns   2834382304
BM_to_average_volume       35557 ns        35548 ns        19675
BM_to_average_volume2       1098 ns         1098 ns       643521
BM_to_size                 0.358 ns        0.358 ns   1967763032
BM_to_first                0.258 ns        0.258 ns   2712873706
BM_to_last                 0.263 ns        0.263 ns   2729388099
BM_to_sum                  0.267 ns        0.267 ns   2686748128
BM_to_sum2                 0.269 ns        0.269 ns   2505319518
BM_to_spot                 0.284 ns        0.284 ns   2571337044
BM_identity                  102 ns          102 ns      6906853
BM_identity2                 101 ns          101 ns      6954593
BM_to_profit               0.251 ns        0.251 ns   2788815489
BM_to_time                 0.249 ns        0.249 ns   2797709090
BM_to_open                 0.251 ns        0.251 ns   2817369761
BM_to_high                 0.248 ns        0.248 ns   2815965783
BM_to_low                  0.252 ns        0.252 ns   2813714212
BM_to_close                0.260 ns        0.260 ns   2824714558
BM_to_volume               0.255 ns        0.255 ns   2658570999