Python crypto backtesting without the most common illusions
A profitable chart is not evidence by itself. A credible research process must make it difficult for accidental foresight, favorable fills, ignored costs, and parameter luck to survive.
1. Execute on the next bar
If a strategy uses a candle's close to calculate a signal, it does not know that signal until the candle has finished. Filling at the same close introduces look-ahead bias. A conservative engine records the signal at bar t and fills at bar t+1, usually with an adverse tick or spread assumption.
2. Charge every realistic cost
Apply exchange fees on entry and exit, model spread or slippage, and round quantities to contract rules. When both a stop and profit target are touched inside one candle and tick order is unknown, process the adverse outcome first. This prevents ambiguous bars from becoming free optimism.
3. Keep time in order
Random train/test splits leak future market regimes into the past. Use chronological segments: develop on the earliest block, validate on the middle block, and reserve the final block for a single confirmation. Walk-forward windows can repeat this process while preserving causality.
4. Reject concentration and instability
Net return alone hides fragile behavior. Track expectancy, maximum drawdown, trade count, win/loss size, stability across windows, and the share of profit contributed by the best trade. Reject candidates that depend on a single outlier or collapse outside one period.
5. Make every run reproducible
Store the input range, parameters, assumptions, metrics, rejection reasons, and software version in deterministic JSON or Markdown. A result that cannot be regenerated is not an auditable research result.
The public demo is dependency-free, uses deterministic fixture prices, executes signals on the next bar, charges fees, and reports drawdown.
Download the free Python demoFull research workflow
The Strategy Research Kit adds public MEXC data ingestion, conservative execution simulation, four strategy families, chronological gates, deterministic reports, and guarded Pine v6 export.
Inspect the sample report or get the complete source for 19 USDT.
Research software only. Not financial advice, signals, or a promise of profit.