Skip to content

Optimization

Parameter optimization (sweeps) test your strategy across many parameter combinations to find the best configuration.

Running a Sweep

Via CLI

bash
tradectl sweep \
  -d data/prepared.bin \
  -r order_size=50:500:50 \
  -r threshold=0.5:2.0:0.1 \
  -p leverage=5 \
  --balance 10000 \
  --taker-fee 0.0004 \
  --maker-fee 0.0002 \
  --top 20 \
  --min-trades 5 \
  -o results.json
FlagDescriptionDefault
-d, --data <PATH>Path to prepared data file(required)
-r, --range <KEY=MIN:MAX:STEP>Parameter range to sweep (repeatable)(required)
-p, --param <KEY=VALUE>Fixed parameters (repeatable)
--balance <FLOAT>Initial balance10000
--leverage <FLOAT>Leverage multiplier1.0
--taker-fee <FLOAT>Taker fee rate0.0004
--maker-fee <FLOAT>Maker fee rate0.0002
--slippage <FLOAT>Slippage percentage0.0001
--top <N>Show top N results20
--min-trades <N>Minimum trades to include5
-o, --output <PATH>Save results as JSON

Via Dashboard

  1. Go to Backtests > New Optimization
  2. Select strategy and configure base settings
  3. Define parameter ranges and step sizes
  4. Select ranking metric (PnL, Sharpe, Calmar, Score)
  5. Click Run

Progress and results stream in real-time.

Ranking Metrics

MetricDescription
PnLNet profit percentage
SharpeRisk-adjusted return
CalmarPnL / max drawdown
Win RatePercentage of winning trades
Profit FactorGross profit / gross loss
Scorepnl% / (1 + max_dd%) * trade_factor

Batch Engine

Sweeps use the BatchStrategy trait — a Structure of Arrays (SoA) interface that evaluates many parameter sets simultaneously in a single pass through the data:

rust
pub trait BatchStrategy {
    fn process_ticker(&mut self, ticker: &TickerEvent);
    fn check_trade(&mut self, trade: &TradeEvent);
    fn force_close_all(&mut self);
}

tradectl — Automate Crypto Trading