Video: https://imgur.com/a/FeuPgQz
New to this sub and algo trading, have been coding for 2 years. I had time to kill yesterday and wrote a basic backtesting tool which allows to download datasets from Binance with Python / CCXT and run strategies and parameters against them. For now I have only implemented moving average crossover / golden cross.
Once it was finished I realized that manually trying several values is very time consuming and not the way to go, so I wrote a second tool that can try the same strategy and dataset against every target / stop combination in a given range.
Strategy: buy on golden cross, sell on target/stop
Data set: 1 year in 1 minute candles (+-525000 candles) BTC/USDC 1/1/25 - 12/31/25 Binance
Target: Try all values between 1% and 20% in 0.1% increments
Stop: Try all values between 0.5% and 10% in 0.1% increments
18336 possible combinations - crunch time on Mac Mini M4:
V1: single core - 1500 minutes
V2: 8 cores - 300 minutes
V3: 8 cores + Numpy + global arrays - 10 minutes
V4: 8 cores + Numpy + global arrays + Numba JIT - 3 seconds
1500 minutes to 3 seconds only with code optimization!
The results were pretty interesting! Target 4% - stop 9.8% was the winner with 17% PnL (pic 3). This was done with linear investments, so always the same trade size. When compounding profits and losses, results were far worse (pic 4). So much worse that I had to manually verify a couple results before I could believe them!
I look forward to trying more strategies, combinations of strategies and experimenting with things like technical exits to see if I can mitigate losses.