The run Command
The run command executes a strategy backtest. This chapter provides a comprehensive guide to all available options.
Basic usage
algo run --strategy <name> --symbols <symbols> [flags]At minimum, a strategy and at least one symbol must be specified.
Date range
| Flag | Default | Description |
|---|---|---|
--date-from | 2010-01-01 | Start date (YYYY-MM-DD) |
--date-to | Today | End date (YYYY-MM-DD) |
--use-first N | Use only the first N% of data (in-sample) | |
--use-last N | Use only the last N% of data (out-of-sample) |
algo run --strategy kbt --symbols @ES --date-from 2015-01-01 --date-to 2024-12-31The --use-first and --use-last flags are useful for dividing data into in-sample and out-of-sample periods:
# Train on first 70%
algo run --strategy kbt --symbols @ES --use-first 70
# Test on last 30%
algo run --strategy kbt --symbols @ES --use-last 30Bar configuration
| Flag | Default | Description |
|---|---|---|
--bar-interval | daily | Bar size: daily, weekly, monthly, Nm, Nh |
--bar-building-mode | natural | natural or session |
--max-bars-back | 263 | Maximum lookback period |
--no-look-inside-bar | false | Disable intra-bar order evaluation |
--bouncing-ticks | 0 | Bouncing ticks percentage (0-100) |
Session configuration
| Flag | Default | Description |
|---|---|---|
--session-hours | Symbol default | Trading hours (e.g., 9:30am-4:00pm) |
--session-days | Symbol default | Trading days (e.g., Mon-Fri) |
--timezone | Exchange timezone | IANA timezone (e.g., America/New_York) |
--no-out-of-session-execution | false | Disable shadow bar processing |
Cost model
Slippage
| Flag | Default | Description |
|---|---|---|
--slippage-mode | per-unit | per-unit or per-trade |
--slippage-ticks | 0 | Number of ticks of slippage |
Commission
| Flag | Default | Description |
|---|---|---|
--commission-mode | per-unit | per-unit, per-trade, or percentage |
--commission-amount | 0 | Commission amount (supports currency: 2.50USD) |
--commission-percentage | 0 | Commission as percentage of trade value |
Capital and position sizing
| Flag | Default | Description |
|---|---|---|
--initial-capital | 1000000 | Starting capital (supports formats: USD100000, 100,000 USD) |
--position-size | 1 | Default contracts/shares per trade |
--risk-free-rate | 0.04 | Annual risk-free rate for Sharpe calculation |
Direction control
| Flag | Default | Description |
|---|---|---|
--dir-long-only | false | Allow only long positions |
--dir-short-only | false | Allow only short positions |
--no-pyramiding | true | Disable pyramiding |
Strategy inputs
Override strategy input defaults from the command line:
algo run --strategy macrossover --symbols @ES --inputs LenFast=5,LenSlow=50Multiple inputs are comma-separated. Values must match the type of the corresponding struct field.
Data detrending
Apply logarithmic detrending to remove trend bias:
algo run --strategy kbt --symbols @ES --detrend 0 --detrend-mode simpleThe --detrend argument specifies which data series indices to detrend (0-based). The mode can be simple or regression.
Parallel execution
When running multiple symbols, use --parallel to run them concurrently:
algo run --strategy kbt --symbols @ES,@NQ,@GC,@CL --parallel 8The default is 64 workers. Use --parallel 0 for sequential execution.
Symbol specification
The --symbols flag supports flexible syntax:
| Syntax | Meaning | Example |
|---|---|---|
@ES | Single symbol | One run on E-mini S&P |
@ES,@NQ | Comma-separated | Separate runs per symbol |
@ES/@NQ | Slash-separated | One run with multiple legs |
<metals | Portfolio reference | One run per symbol in the file |
<metals/@NQ | Mixed | Each metal paired with @NQ |
<metal/<soft | Cartesian product | Every metal x every soft |