DocsRun Modes
Backtest
A backtest replays your strategy against historical candles to simulate how it would have traded. It is the fastest way to see whether a strategy idea has merit.
How It Works
- Candles are fetched for the chosen symbol, interval, and date range
- Your strategy's
define(),init(), andonBar()functions are called in sequence - The trading engine simulates order fills, portfolio tracking, and fee deduction
- Results include every trade, performance stats, and an equity curve
Inputs
| Setting | Description |
|---|---|
| Symbol | Trading pair (e.g. BTCUSDT) |
| Interval | Candle timeframe (1h, 4h, 1d, etc.) |
| Date range | Start and end dates, or candle index range |
| Strategy | Your QSL strategy |
| Parameters | Values for each parameter defined in define() |
| Allocation | Starting capital (default 10,000 USDT) |
| Trading mode | LONG_ONLY, SHORT_ONLY, or BIDIRECTIONAL |
| Fee % | Per-trade fee (default 0.1%) |
Trading Modes
| Mode | Description |
|---|---|
| LONG_ONLY | Only long (buy) positions. This is the default. |
| SHORT_ONLY | Only short (sell) positions. Automatically uses MIXED portfolio. |
| BIDIRECTIONAL | Both long and short positions allowed. |
Output
A completed backtest returns:
- Trades — every entry and exit with prices, dates, P&L, and portfolio snapshots
- Statistics — trade count, win rate, total return, Sharpe ratio, max drawdown, profit factor, Calmar ratio
- Signals — the raw signal array from your strategy
- Metadata — symbol, interval, candle count, fee rate, and whether data was truncated
Candle Limits
Very large date ranges are automatically capped to prevent excessive memory usage. If your range exceeds the system limit (~50,000 candles), only the most recent candles are used and a warning is included in the metadata.
Tips
- Start with a single instrument and a wide date range to see overall behaviour
- Use the default parameters first, then move to Optimization to tune them
- Compare LONG_ONLY vs BIDIRECTIONAL to see if short signals add value
- Check the max drawdown — a high return with extreme drawdown is risky
backtestrunsimulationtradesequitystatssingle run