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 May 30 17:36:32 UTC 2024 by a Ubuntu 24.04 LTS.
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.97% average profit over 75 trades.
Time | Token | Open | Close | Hours | Profit |
---|---|---|---|---|---|
2024-05-27 22:00:00 | Kraken-XRT-EUR | 7.63 | 7.11 | 46 | -6.9% |
2024-05-24 16:00:00 | Binance-ETH-EUR | 3396.13 | 3502.20 | 41 | 3.1% |
2024-05-22 04:00:00 | Kraken-RUNE-EUR | 6.19 | 5.78 | 33 | -6.6% |
2024-05-22 04:00:00 | Kraken-SOL-EUR | 162.89 | 152.47 | 52 | -6.4% |
2024-05-21 16:00:00 | Kraken-MSOL-EUR | 196.15 | 202.66 | 18 | 3.3% |
2024-05-20 22:00:00 | Kraken-XRT-EUR | 7.53 | 7.76 | 3 | 3.1% |
2024-05-13 22:00:00 | Kraken-GMX-EUR | 26.20 | 27.34 | 39 | 4.4% |
2024-05-13 12:00:00 | Kraken-LPT-GBP | 13.50 | 14.12 | 5 | 4.6% |
2024-05-08 16:00:00 | Kraken-BCH-EUR | 425.99 | 395.50 | 48 | -7.2% |
2024-05-08 16:00:00 | Coinbase-BCH-GBP | 366.34 | 340.45 | 48 | -7.1% |
2024-04-30 00:00:00 | Kraken-EUL-EUR | 5.47 | 5.64 | 1 | 3.1% |
2024-04-29 22:00:00 | Coinbase-ENS-EUR | 15.03 | 14.00 | 12 | -6.8% |
2024-04-29 19:00:00 | Coinbase-ICP-EUR | 12.48 | 11.73 | 17 | -6.0% |
2024-04-29 19:00:00 | Binance-ICP-EUR | 12.48 | 11.72 | 17 | -6.1% |
2024-04-29 12:00:00 | Kraken-MLN-EUR | 20.35 | 18.98 | 24 | -6.8% |
2024-04-24 14:00:00 | Binance-NEAR-EUR | 6.44 | 6.69 | 3 | 3.9% |
2024-04-24 14:00:00 | Kraken-NEAR-EUR | 6.43 | 6.69 | 3 | 4.0% |
2024-04-24 08:00:00 | Kraken-LPT-EUR | 14.34 | 13.45 | 8 | -6.2% |
2024-04-24 02:00:00 | Kraken-AKT-EUR | 5.11 | 4.78 | 4 | -6.5% |
2024-04-23 20:00:00 | Coinbase-AVAX-EUR | 35.98 | 33.61 | 30 | -6.6% |
2024-04-23 20:00:00 | Binance-AVAX-EUR | 36.01 | 33.66 | 30 | -6.5% |
2024-04-23 20:00:00 | Kraken-AVAX-EUR | 35.96 | 33.78 | 30 | -6.1% |
2024-04-23 16:00:00 | Kraken-RNDR-EUR | 8.57 | 8.06 | 28 | -6.0% |
2024-04-16 13:00:00 | Coinbase-AXS-EUR | 6.47 | 6.69 | 58 | 3.3% |
2024-04-16 13:00:00 | Coinbase-DOT-EUR | 6.17 | 6.38 | 56 | 3.3% |
2024-04-16 13:00:00 | Coinbase-ETC-GBP | 20.73 | 21.37 | 16 | 3.1% |
2024-04-16 13:00:00 | Kraken-KP3R-EUR | 74.13 | 75.40 | 67 | 1.7% |
2024-04-16 13:00:00 | Kraken-AXS-EUR | 6.50 | 6.71 | 66 | 3.2% |
2024-04-16 13:00:00 | Kraken-LTC-GBP | 62.81 | 64.72 | 34 | 3.0% |
2024-04-10 11:00:00 | Kraken-XMR-EUR | 123.20 | 114.31 | 56 | -7.2% |
2024-04-09 01:00:00 | Kraken-MLN-EUR | 23.48 | 24.57 | 16 | 4.6% |
2024-04-02 02:00:00 | Kraken-BCH-EUR | 585.44 | 548.66 | 38 | -6.3% |
2024-04-02 02:00:00 | Coinbase-MASK-EUR | 5.18 | 5.36 | 5 | 3.5% |
2024-04-02 02:00:00 | Binance-BCH-EUR | 586.80 | 549.20 | 38 | -6.4% |
2024-04-02 02:00:00 | Coinbase-AAVE-EUR | 116.80 | 109.13 | 6 | -6.6% |
2024-04-02 02:00:00 | Coinbase-ICP-GBP | 14.18 | 14.66 | 28 | 3.4% |
2024-04-02 02:00:00 | Coinbase-FIL-GBP | 7.25 | 6.78 | 22 | -6.5% |
2024-04-02 02:00:00 | Coinbase-BCH-EUR | 586.65 | 548.92 | 38 | -6.4% |
2024-04-01 14:00:00 | Binance-ICP-EUR | 16.78 | 15.77 | 15 | -6.0% |
2024-04-01 14:00:00 | Kraken-BADGER-EUR | 6.26 | 5.85 | 35 | -6.6% |
2024-04-01 14:00:00 | Coinbase-ICP-GBP | 14.35 | 13.37 | 19 | -6.8% |
2024-03-31 07:00:00 | Kraken-FIL-EUR | 8.90 | 9.31 | 17 | 4.5% |
2024-03-30 14:00:00 | Kraken-MASK-EUR | 5.21 | 5.41 | 42 | 3.7% |
2024-03-30 06:00:00 | Kraken-KP3R-EUR | 89.90 | 96.27 | 15 | 7.1% |
2024-03-29 18:00:00 | Coinbase-SOL-GBP | 147.33 | 152.23 | 5 | 3.3% |
2024-03-29 16:00:00 | Kraken-SOL-GBP | 146.98 | 152.30 | 7 | 3.6% |
2024-03-29 04:00:00 | Kraken-LTC-GBP | 74.28 | 76.96 | 5 | 3.6% |
2024-03-28 09:00:00 | Kraken-MLN-EUR | 25.51 | 23.87 | 23 | -6.4% |
2024-03-27 19:00:00 | Kraken-KP3R-EUR | 89.37 | 92.20 | 28 | 3.2% |
2024-03-26 08:00:00 | Kraken-XRT-EUR | 6.39 | 5.90 | 28 | -7.6% |
2024-03-23 21:00:00 | Kraken-MLN-EUR | 25.71 | 23.89 | 14 | -7.1% |
2024-03-22 22:00:00 | Kraken-LTC-GBP | 65.49 | 68.18 | 12 | 4.1% |
2024-03-22 22:00:00 | Kraken-ATOM-GBP | 8.91 | 9.20 | 17 | 3.4% |
2024-03-22 22:00:00 | Kraken-AAVE-GBP | 92.21 | 96.35 | 4 | 4.5% |
2024-03-22 22:00:00 | Coinbase-LTC-EUR | 76.28 | 79.53 | 12 | 4.3% |
2024-03-22 22:00:00 | Coinbase-AAVE-GBP | 92.20 | 96.14 | 4 | 4.3% |
2024-03-22 22:00:00 | Coinbase-AAVE-EUR | 107.30 | 110.73 | 3 | 3.2% |
2024-03-22 10:00:00 | Coinbase-SOL-GBP | 139.66 | 145.31 | 60 | 4.0% |
2024-03-18 23:00:00 | Binance-ICP-EUR | 11.35 | 10.58 | 6 | -6.8% |
2024-03-17 16:00:00 | Kraken-FORTH-EUR | 4.88 | 5.06 | 2 | 3.6% |
2024-03-17 15:00:00 | Coinbase-AVAX-EUR | 50.51 | 52.23 | 4 | 3.4% |
2024-03-17 07:00:00 | Binance-APT-EUR | 12.54 | 13.34 | 1 | 6.4% |
2024-03-17 07:00:00 | Kraken-APT-EUR | 12.47 | 13.31 | 1 | 6.8% |
2024-03-17 07:00:00 | Coinbase-RNDR-EUR | 9.72 | 10.21 | 2 | 5.0% |
2024-03-15 17:00:00 | Kraken-DOT-EUR | 9.48 | 9.91 | 2 | 4.5% |
2024-03-15 17:00:00 | Kraken-MKR-EUR | 2520.07 | 2599.13 | 7 | 3.1% |
2024-03-15 17:00:00 | Binance-LINK-EUR | 17.77 | 16.66 | 30 | -6.2% |
2024-03-15 03:00:00 | Kraken-AVAX-EUR | 48.91 | 45.83 | 6 | -6.3% |
2024-03-15 03:00:00 | Kraken-EGLD-EUR | 63.74 | 65.71 | 4 | 3.1% |
2024-03-15 03:00:00 | Coinbase-AVAX-EUR | 48.93 | 45.89 | 6 | -6.2% |
2024-03-15 03:00:00 | Binance-EGLD-EUR | 64.27 | 60.29 | 35 | -6.2% |
2024-03-15 03:00:00 | Binance-AVAX-EUR | 48.91 | 45.88 | 6 | -6.2% |
2024-03-14 13:00:00 | Kraken-UNI-EUR | 12.86 | 12.07 | 14 | -6.1% |
2024-03-14 13:00:00 | Coinbase-UNI-EUR | 12.87 | 12.06 | 14 | -6.3% |
2024-03-12 17:00:00 | Kraken-QTUM-EUR | 4.64 | 4.83 | 2 | 3.9% |
Benchmarks
---------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------- BM_is_entry 52629 ns 52629 ns 12794 BM_is_entry2 41321 ns 41318 ns 16974 BM_to_exit 204 ns 204 ns 3415754 BM_to_exit2 216 ns 216 ns 3228192 BM_to_vwap 7535 ns 7517 ns 93167 BM_to_vwap2 7503 ns 7502 ns 93292 BM_is_recent_dip2 792 ns 792 ns 884942 BM_to_atr 62793 ns 62793 ns 11199 BM_to_atr2 2553 ns 2549 ns 272911 BM_to_atr3 2534 ns 2534 ns 276541 BM_to_average_func 0.330 ns 0.330 ns 1000000000 BM_to_average_func2 0.628 ns 0.628 ns 1000000000 BM_to_average_volume 58463 ns 58462 ns 11803 BM_to_average_volume2 1884 ns 1884 ns 372642 BM_to_size 0.508 ns 0.508 ns 1000000000 BM_to_first 0.628 ns 0.627 ns 1000000000 BM_to_last 0.334 ns 0.334 ns 1000000000 BM_to_sum 0.336 ns 0.336 ns 1000000000 BM_to_sum2 0.333 ns 0.333 ns 1000000000 BM_to_spot 0.329 ns 0.329 ns 1000000000 BM_identity 170 ns 170 ns 4126569 BM_identity2 170 ns 170 ns 4127904 BM_to_profit 0.332 ns 0.332 ns 1000000000 BM_to_time 0.332 ns 0.332 ns 1000000000 BM_to_open 0.336 ns 0.336 ns 1000000000 BM_to_high 0.334 ns 0.334 ns 1000000000 BM_to_low 0.331 ns 0.331 ns 1000000000 BM_to_close 0.624 ns 0.624 ns 1000000000 BM_to_volume 0.339 ns 0.339 ns 1000000000