Skip to content

First Backtest

With the dev stack running and market data seeded, you can run a backtest and inspect results in gordon-console.

The backtest = live invariant

Gordon has one strategy evaluation code path. The same Strategy::evaluate function runs inside gordon-bot's live loop and inside gordon-manager's backtest replay engine (BacktestExecution). There is no shadow engine, no Python reimplementation, no separate simulation model. A CI byte-parity gate (tests/it_backtest_live_byte_parity.rs) enforces this at every push.

This means backtest results are structurally trustworthy: what you see in the backtest is what the bot would have done.

Run a backtest via the console

Open http://localhost:3000 and navigate to Research in the sidebar. Select a strategy, symbol, and timeframe, then click Run Backtest.

Results appear in the runs list once the replay completes. Click a run to see:

  • Performance stats (Sharpe, max drawdown, CAGR, win rate)
  • Equity curve with drawdown overlay
  • Roundtrip table with individual trade PnL, duration, and fees

Run a backtest via the BFF API

The manager BFF exposes a REST endpoint directly:

bash
curl -X POST http://localhost:8083/backtest \
  -H "Authorization: Bearer dev-operator-token" \
  -H "Content-Type: application/json" \
  -d '{
    "strategy": "supertrend",
    "symbol": "BTCUSDT",
    "timeframe": "1d",
    "from_ts": 1704067200000,
    "to_ts": 1735689600000,
    "params": {
      "atr_period": 10,
      "multiplier": 3.0
    }
  }'

The response body contains a run_id. Query the run directly:

bash
curl http://localhost:8083/runs/{run_id} \
  -H "Authorization: Bearer dev-operator-token"

Available strategies

Strategystrategy valueValidated timeframes
Supertrend 3.0supertrend1d, 8h
EWMAC ensembleewmac6h, 4h, 2h, 1h
PSAR tightpsar1w, 1d

The 11 strategies added in 4.6.x (basis_revert, bollinger_breakout, funding_arb, hurst_regime_switcher, opening_range_breakout, pairs_mr, rsi_mean_reversion, tsmom, volume_spike_breakout, vpin_impulse, vwap_stretch_mr) are registered in the StrategyRegistry and available for backtesting, but their walk-forward validation is still in progress.

Interpreting results

  • Sharpe ratio is annualized. Above 0.5 is acceptable for trend-following; above 0.9 is the current production threshold.
  • Max drawdown shows the worst peak-to-trough decline. Trend-following systems routinely see 20-40% drawdowns — this is expected.
  • Fees are included. The backtest applies Binance VIP 0 taker fees (4 bps) and estimated slippage per asset. Results are net of costs.
  • Walk-forward validation separates real edge from curve-fitting. A single full-history backtest is not sufficient — see Walk-Forward Testing for the proper methodology.

Database tables written

Each backtest run writes to:

TableContent
runsOne row per run — strategy, symbol, timeframe, parameters, timestamps
tradesIndividual fills (entry and exit)
roundtripsMatched entry-exit pairs with PnL, duration, fees
equity_pointsAccount balance over time
performance_snapshotsAggregate metrics

Query directly if needed:

bash
make dev-psql
sql
SELECT id, strategy, symbol, timeframe, sharpe, max_drawdown_pct
FROM runs
ORDER BY created_at DESC
LIMIT 10;

Next step

Now that you have results, read Project Structure to understand how the v7 workspace is organized.

Gordon — keep compounding without blowing up