Module 2 ยท Implementation
Lesson 4 โ€” Backtesting
โฑ 18 minutes๐Ÿ”’ Paid

Why backtest

Before investing real money, find out how your strategy would have worked on historical data. If it was unprofitable in the past, it will likely be unprofitable in the future.

Source โ€” Binance Historical Data

Binance provides free OHLCV (Open/High/Low/Close/Volume) data for the entire time period. You can access it via REST or bulk download.

๐Ÿ‘ค Prompt
Create a backtester in your grid-bot: 1. data_loader.py: download OHLCV ETHUSDT 1-minute data for the last 60 days via the Binance API. Save it in parquet format. 2. simulator.py: - Load the data. - Initialize the grid with the same parameters as your live config. - Go through each minute: - If the price touches the buy level โ†’ simulate a fill, add a sell order at the next level. - If the sell level is reached โ†’ fill, buy at the next level. - Track: filled orders, position size, USD value. 3. report.py: - Total profit/loss over 60 days. - Daily breakdown. - Maximum drawdown. - Win rate (filled grid trades). - If there was a breakout โ€” what happened. Run the backtest. Show the report + equity curve graph.

What to look for in the results

MetricGood indicator
Total return over 60 days+5-15%
Max drawdown<-10%
Daily P&L distributionMost days are profitable
Breakout events<3 in 60 days
Sharpe ratio>1.5 (excellent >2.5)

Walk-forward optimization

If you want to optimize parameters (step, range) โ€” don't do it on the entire dataset. Otherwise, you'll overfit.

๐Ÿ‘ค Prompt
Add walk-forward.py to your backtester: 1. Split historical data into 70/30 (train/test). 2. On the train data โ€” try different step values (0.5, 1, 1.5, 2, 3%) and range values (ยฑ3%, ยฑ5%, ยฑ8%, ยฑ10%). 3. Choose the best parameters based on the Sharpe ratio. 4. On the test data โ€” check how they work (out-of-sample). 5. If the test results are <30% worse than the train results โ€” it means overfitting, don't use them. Show the top 5 combinations + their out-of-sample performance.

Reality check

Backtesting shows an idealized picture. A real bot can be 20-40% worse:

So if backtesting showed +12% โ€” expect 6-8% in reality. If backtesting showed -5% โ€” RUN, reality will be worse.

๐Ÿ’ก Pre-flight checklist

Before mainnet:
โœ… Backtest for 60+ days โ€” net positive
โœ… Walk-forward โ€” out-of-sample not deg more than 30%
โœ… Drawdown <10%
โœ… Sharpe >1.5
If all 4 โ€” launch. If any of them are not met โ€” the parameters are not suitable.

๐ŸŽฏ Key takeaway

Backtest for 60 days. Walk-forward to avoid overfitting. Realistic expectation โ€” 70% of backtest results. In the next lesson โ€” risk management and breakout protection.

โ† Lesson 3Lesson 5: Risk management โ†’