This is research, not financial advice. Backtests are hypothetical, past performance does not predict future results, and crypto can lose all of your capital. The bot in this post is testnet-only: it trades only on Binance's Spot Testnet (fake money) and refuses to run against real funds.
📄 Technical report: Simple Rule-Based Trading Strategies on Bitcoin and Ether: A Reproducible Backtest (Zenodo, DOI 10.5281/zenodo.24689183) · Code: github.com/mafzalkalwardev/binance-trading-bot
It's easy to make a backtest look amazing: try enough parameters on one history and something will. So for binance-trading-bot I set myself two rules: keep the strategies simple and the checks strict, and make the whole thing reproducible from raw public data with two commands.
Then I did the reproducibility test for real: a fresh clone, fresh environment, fresh data download, full re-run.
The setup
Data: Binance spot BTC/USDT and ETH/USDT, 1h and 4h candles, from January 2020, downloaded from the public archive (data.binance.vision) plus the REST API for the current month. No API keys.
Strategies (long-only spot):
- EMA crossover: fast EMA crosses above slow EMA, exit on reverse cross or ATR trailing stop (24 parameter combos)
- Donchian breakout: close above the previous N-bar high, exit below the previous M-bar low or a fixed ATR stop, turtle-style (14 combos)
- RSI mean reversion: RSI below a threshold while above the 200 EMA (24 combos)
- Buy-and-hold as the benchmark
Execution realism:
- signal on bar close → fill at next bar's open (no look-ahead)
- 0.1% fee + 0.05% slippage per fill
- stops checked intrabar against high/low; gaps fill at the worse open
- 1% of equity risked per trade, no leverage
Anti-overfitting checks:
- choose parameters on 2020–2023 only (best Sharpe with ≥ 20 trades)
- test them unchanged on 2024 → now
- walk-forward: re-optimise every 6 months on the previous 24, stitch the test segments
- neighbourhood check: how do the parameter settings one step away perform?
The reproducibility test
pip install -r requirements.txt python -m pytest -q tests # 10 passed python -m tradebot.data # ~7.5 min download python run_backtests.py # ~1.7 min on an 8-vCPU VM Compared with the results I had committed (data to 25 November 2026), the re-run (data to 29 November 2026):
- picked identical parameters in all 84 result rows
- matched every in-sample metric exactly
- changed out-of-sample numbers only marginally, purely because of four extra days of data
Out-of-sample results (2024-01 → 2026-11-29)
| Series | Rule | Return | Max DD | Sharpe | Trades |
|---|---|---|---|---|---|
| BTC 4h | buy-and-hold | +41.7% | −54.8% | 0.49 | – |
| BTC 4h | Donchian 100/20 | +13.7% | −14.8% | 0.50 | 43 |
| ETH 4h | buy-and-hold | −27.5% | −68.0% | 0.17 | – |
| ETH 4h | EMA 10/50 | +20.7% | −6.3% | 0.90 | 86 |
| ETH 4h | Donchian 55/50 | +37.7% | −15.8% | 0.96 | 37 |
| BTC 1h | EMA 20/50 | −15.4% | −23.8% | −0.55 | 240 |
| ETH 1h | RSI 14 | −7.4% | −9.1% | −0.78 | 25 |
What survived
- 4h Donchian breakout was the only rule family positive out-of-sample on both coins with every single grid setting profitable. Walk-forward Sharpe: 0.61 on BTC (buy-and-hold 0.36) and 0.81 on ETH (buy-and-hold 0.10).
- On BTC, it matched buy-and-hold's Sharpe with far less return and a much smaller drawdown. Nothing beat BTC buy-and-hold on risk-adjusted return by a meaningful margin.
What didn't
- 1h strategies mostly lost money. More trades means more fees and slippage.
- RSI mean reversion looked fine in-sample on 4h and then went flat or negative out-of-sample. Only 17% of its 4h grid settings were profitable OOS.
- Classic overfitting signature: the neighbours of the chosen BTC 1h Donchian setting averaged an in-sample Sharpe of 1.01 and an out-of-sample Sharpe of 0.09.
The paper bot (testnet only)
paperbot/ runs the 4h Donchian settings 24/7 with the same signal code as the backtest:
- signals and stops from mainnet public candles (testnet candles have fake wicks)
- orders only to the Binance Spot Testnet. A hard guard refuses to start unless ccxt sandbox mode is on and every endpoint is the testnet host.
- 1% risk per trade, one position per symbol, a 3% daily loss cap,
PAUSEandKILLfiles - state saved as JSON and reconciled on restart, every order journalled
Its 10 unit tests check things like "live signals equal backtest signals without look-ahead" and "a restart recovers a pending entry."
Caveats you should take seriously
- Small sample: ~2.9 years and ~40 trades per coin. With 24–28% win rates, long losing streaks are normal.
- Regime: ETH fell during the test window, which flatters trend-following with stops.
- No formal data-snooping correction (like White's Reality Check or a deflated Sharpe ratio).
- Small exposure: about 9–11% of capital deployed on average at 1% risk.
- Not modelled: order-book depth, partial fills, outages, taxes, futures funding.
FAQ
Is this a profitable trading strategy?
I'm not claiming that. It's a reproducible study of simple rules with strict checks. The best rule matched BTC buy-and-hold on Sharpe and did well on ETH in a falling market, over a short sample.
Can I reproduce the results?
Yes. Clone the repo, install the requirements, run python -m tradebot.data and python run_backtests.py. In-sample numbers should match exactly; out-of-sample numbers shift slightly as new data arrives.
Why did 1-hour strategies fail?
Mostly costs. They trade several times more often, and 0.1% fees plus slippage per fill add up.
Does the bot trade real money?
No. It refuses to run unless it's pointed at the Binance Spot Testnet.
What's a walk-forward test?
Re-choosing parameters every six months using only the preceding two years, then testing on the next six months, and stitching those test periods together.
What would make the results more convincing?
A longer out-of-sample period, more assets and exchanges, and a formal correction for the number of strategies and parameters tried.
I'm Muhammad Afzal Kalwar, a Rust and Python automation engineer and founder of INDUS Web Agency in Islamabad. The full technical report is on Zenodo: doi.org/10.5281/zenodo.24689183. Code: github.com/mafzalkalwardev/binance-trading-bot.
