Crypto/stock backtester
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
.
Built with ♥ on Thu Jan 16 18:35:54 UTC 2025 by a Ubuntu Plucky Puffin (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.91% average profit over 71 trades.
Time | Token | Open | Close | Hours | Profit |
---|---|---|---|---|---|
2025-01-11 17:00:00 | Kraken-ICP-EUR | 9.93 | 10.25 | 4 | 3.2% |
2025-01-11 17:00:00 | Binance-ICP-EUR | 9.93 | 10.23 | 4 | 3.1% |
2025-01-07 11:00:00 | Coinbase-DOT-EUR | 7.44 | 6.94 | 7 | -6.7% |
2025-01-05 11:00:00 | Kraken-EUL-EUR | 5.20 | 4.89 | 15 | -6.0% |
2025-01-01 18:00:00 | Kraken-RUNE-EUR | 4.37 | 4.51 | 9 | 3.1% |
2025-01-01 17:00:00 | Kraken-SOL-GBP | 151.56 | 156.84 | 8 | 3.5% |
2025-01-01 17:00:00 | Coinbase-SOL-EUR | 183.42 | 189.88 | 8 | 3.5% |
2025-01-01 17:00:00 | Kraken-SOL-EUR | 183.48 | 189.61 | 8 | 3.3% |
2024-12-28 16:00:00 | Kraken-RAY-EUR | 4.75 | 4.91 | 2 | 3.3% |
2024-12-28 15:00:00 | Coinbase-UNI-EUR | 12.78 | 12.97 | 67 | 1.4% |
2024-12-22 23:00:00 | Coinbase-ICP-EUR | 9.55 | 10.01 | 21 | 4.8% |
2024-12-22 23:00:00 | Coinbase-ICP-GBP | 7.91 | 8.29 | 21 | 4.8% |
2024-12-22 14:00:00 | Kraken-ENS-EUR | 33.11 | 34.24 | 30 | 3.4% |
2024-12-22 14:00:00 | Coinbase-ICP-GBP | 7.97 | 8.29 | 30 | 4.1% |
2024-12-22 13:00:00 | Kraken-AVAX-EUR | 36.46 | 37.79 | 34 | 3.6% |
2024-12-22 13:00:00 | Coinbase-ETC-EUR | 25.37 | 26.46 | 32 | 4.3% |
2024-12-22 03:00:00 | Binance-DOT-EUR | 6.68 | 6.90 | 7 | 3.4% |
2024-12-18 14:00:00 | Binance-SOL-EUR | 205.96 | 188.04 | 28 | -8.7% |
2024-12-18 14:00:00 | Coinbase-SOL-GBP | 170.17 | 155.77 | 28 | -8.5% |
2024-12-18 14:00:00 | Kraken-SOL-GBP | 170.14 | 155.66 | 28 | -8.5% |
2024-12-17 09:00:00 | Binance-LTC-EUR | 112.29 | 116.16 | 8 | 3.4% |
2024-12-17 09:00:00 | Coinbase-LTC-GBP | 92.82 | 96.01 | 8 | 3.4% |
2024-12-17 09:00:00 | Coinbase-LTC-EUR | 112.62 | 116.16 | 8 | 3.1% |
2024-12-17 09:00:00 | Kraken-LTC-EUR | 112.08 | 116.06 | 8 | 3.5% |
2024-12-15 05:00:00 | Kraken-ATOM-GBP | 7.05 | 7.52 | 5 | 6.6% |
2024-12-14 07:00:00 | Kraken-ETC-EUR | 32.11 | 31.44 | 67 | -2.1% |
2024-12-13 18:00:00 | Kraken-BCH-EUR | 507.13 | 500.66 | 67 | -1.3% |
2024-12-13 18:00:00 | Coinbase-BCH-GBP | 421.80 | 436.51 | 55 | 3.5% |
2024-12-08 18:00:00 | Kraken-ENS-EUR | 38.65 | 36.27 | 15 | -6.1% |
2024-12-08 18:00:00 | Kraken-APT-EUR | 13.56 | 12.71 | 15 | -6.3% |
2024-12-08 17:00:00 | Coinbase-LTC-GBP | 104.59 | 97.24 | 16 | -7.0% |
2024-12-08 17:00:00 | Coinbase-ATOM-EUR | 9.48 | 8.84 | 16 | -6.7% |
2024-12-08 17:00:00 | Kraken-RAY-EUR | 4.72 | 4.43 | 19 | -6.2% |
2024-12-05 10:00:00 | Kraken-AXS-EUR | 8.83 | 9.10 | 36 | 3.1% |
2024-12-05 09:00:00 | Kraken-ZEC-EUR | 66.57 | 69.28 | 9 | 4.1% |
2024-12-05 01:00:00 | Coinbase-LTC-EUR | 122.45 | 126.37 | 10 | 3.2% |
2024-12-03 11:00:00 | Kraken-FARM-EUR | 53.90 | 58.41 | 1 | 8.4% |
2024-12-03 09:00:00 | Kraken-ENS-EUR | 38.92 | 41.48 | 16 | 6.6% |
2024-12-02 19:00:00 | Kraken-BCH-EUR | 490.21 | 505.96 | 2 | 3.2% |
2024-12-02 19:00:00 | Coinbase-BCH-EUR | 487.13 | 506.31 | 2 | 3.9% |
2024-12-02 19:00:00 | Kraken-ETC-EUR | 31.24 | 32.27 | 2 | 3.3% |
2024-11-29 16:00:00 | Coinbase-ETC-GBP | 25.06 | 25.84 | 11 | 3.1% |
2024-11-26 19:00:00 | Coinbase-AAVE-GBP | 136.52 | 141.27 | 3 | 3.5% |
2024-11-26 07:00:00 | Kraken-NEAR-EUR | 6.19 | 5.78 | 4 | -6.6% |
2024-11-21 03:00:00 | Kraken-BCH-GBP | 346.85 | 368.88 | 1 | 6.4% |
2024-11-20 12:00:00 | Kraken-EGLD-EUR | 28.49 | 26.65 | 15 | -6.5% |
2024-11-20 11:00:00 | Coinbase-UNI-EUR | 8.58 | 8.85 | 27 | 3.2% |
2024-11-20 11:00:00 | Binance-EGLD-EUR | 28.64 | 26.76 | 16 | -6.6% |
2024-11-20 10:00:00 | Kraken-GNO-EUR | 243.95 | 252.00 | 31 | 3.3% |
2024-11-20 07:00:00 | Coinbase-ATOM-GBP | 4.99 | 5.19 | 3 | 4.0% |
2024-11-20 05:00:00 | Binance-DOT-EUR | 5.46 | 5.69 | 4 | 4.0% |
2024-11-18 06:00:00 | Coinbase-ICP-GBP | 7.21 | 7.45 | 12 | 3.3% |
2024-11-18 06:00:00 | Binance-APT-EUR | 11.31 | 12.07 | 51 | 6.7% |
2024-11-15 13:00:00 | Kraken-BCH-GBP | 336.41 | 346.97 | 20 | 3.1% |
2024-11-15 13:00:00 | Binance-BNB-EUR | 588.63 | 593.56 | 67 | 0.8% |
2024-11-15 13:00:00 | Coinbase-BCH-EUR | 406.57 | 419.98 | 21 | 3.3% |
2024-11-15 05:00:00 | Kraken-KP3R-EUR | 23.77 | 26.77 | 12 | 12.6% |
2024-11-14 23:00:00 | Kraken-SOL-EUR | 200.05 | 207.29 | 23 | 3.6% |
2024-11-14 17:00:00 | Kraken-FARM-EUR | 40.18 | 36.43 | 13 | -9.3% |
2024-11-13 14:00:00 | Coinbase-DOT-EUR | 4.96 | 4.58 | 25 | -7.7% |
2024-11-13 14:00:00 | Kraken-DOT-EUR | 4.95 | 4.58 | 25 | -7.5% |
2024-11-13 00:00:00 | Kraken-LPT-EUR | 10.78 | 9.96 | 4 | -7.6% |
2024-11-12 21:00:00 | Binance-LTC-EUR | 71.34 | 74.04 | 30 | 3.8% |
2024-11-11 16:00:00 | Kraken-RAY-EUR | 5.05 | 4.75 | 8 | -6.0% |
2024-11-11 14:00:00 | Binance-LINK-EUR | 13.08 | 13.51 | 2 | 3.3% |
2024-11-11 14:00:00 | Coinbase-LINK-EUR | 13.07 | 13.53 | 2 | 3.5% |
2024-11-11 14:00:00 | Coinbase-LINK-GBP | 10.82 | 11.30 | 3 | 4.4% |
2024-11-11 14:00:00 | Coinbase-UNI-GBP | 6.91 | 7.15 | 3 | 3.5% |
2024-11-11 05:00:00 | Coinbase-LINK-GBP | 10.83 | 11.30 | 12 | 4.3% |
2024-11-11 05:00:00 | Coinbase-UNI-EUR | 8.45 | 9.04 | 21 | 6.9% |
2024-11-11 05:00:00 | Kraken-YFI-EUR | 6353.67 | 5947.67 | 29 | -6.4% |
Benchmarks
---------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------- BM_is_entry 55653 ns 55653 ns 12455 BM_is_entry2 42343 ns 42342 ns 16554 BM_to_exit 238 ns 238 ns 2950242 BM_to_exit2 221 ns 221 ns 3157490 BM_to_vwap 7510 ns 7509 ns 93071 BM_to_vwap2 7514 ns 7513 ns 93375 BM_is_recent_dip2 802 ns 802 ns 872183 BM_to_atr 65093 ns 65092 ns 10791 BM_to_atr2 2382 ns 2382 ns 293296 BM_to_atr3 2536 ns 2536 ns 278155 BM_to_average_func 0.314 ns 0.314 ns 1000000000 BM_to_average_func2 0.312 ns 0.312 ns 1000000000 BM_to_average_volume 59698 ns 59698 ns 11733 BM_to_average_volume2 1879 ns 1879 ns 371430 BM_to_size 0.507 ns 0.507 ns 1000000000 BM_to_first 0.313 ns 0.313 ns 1000000000 BM_to_last 0.311 ns 0.311 ns 1000000000 BM_to_sum 0.315 ns 0.315 ns 1000000000 BM_to_sum2 0.311 ns 0.311 ns 1000000000 BM_to_spot 0.312 ns 0.312 ns 1000000000 BM_identity 158 ns 158 ns 4430086 BM_identity2 158 ns 158 ns 4426834 BM_to_profit 0.313 ns 0.313 ns 1000000000 BM_to_time 0.312 ns 0.312 ns 1000000000 BM_to_open 0.314 ns 0.314 ns 1000000000 BM_to_high 0.312 ns 0.312 ns 1000000000 BM_to_low 0.312 ns 0.311 ns 1000000000 BM_to_close 0.313 ns 0.313 ns 1000000000 BM_to_volume 0.313 ns 0.313 ns 1000000000