The run Command

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

FlagDefaultDescription
--date-from2010-01-01Start date (YYYY-MM-DD)
--date-toTodayEnd date (YYYY-MM-DD)
--use-first NUse only the first N% of data (in-sample)
--use-last NUse only the last N% of data (out-of-sample)
algo run --strategy kbt --symbols @ES --date-from 2015-01-01 --date-to 2024-12-31

The --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 30

Bar configuration

FlagDefaultDescription
--bar-intervaldailyBar size: daily, weekly, monthly, Nm, Nh
--bar-building-modenaturalnatural or session
--max-bars-back263Maximum lookback period
--no-look-inside-barfalseDisable intra-bar order evaluation
--bouncing-ticks0Bouncing ticks percentage (0-100)

Session configuration

FlagDefaultDescription
--session-hoursSymbol defaultTrading hours (e.g., 9:30am-4:00pm)
--session-daysSymbol defaultTrading days (e.g., Mon-Fri)
--timezoneExchange timezoneIANA timezone (e.g., America/New_York)
--no-out-of-session-executionfalseDisable shadow bar processing

Cost model

Slippage

FlagDefaultDescription
--slippage-modeper-unitper-unit or per-trade
--slippage-ticks0Number of ticks of slippage

Commission

FlagDefaultDescription
--commission-modeper-unitper-unit, per-trade, or percentage
--commission-amount0Commission amount (supports currency: 2.50USD)
--commission-percentage0Commission as percentage of trade value

Capital and position sizing

FlagDefaultDescription
--initial-capital1000000Starting capital (supports formats: USD100000, 100,000 USD)
--position-size1Default contracts/shares per trade
--risk-free-rate0.04Annual risk-free rate for Sharpe calculation

Direction control

FlagDefaultDescription
--dir-long-onlyfalseAllow only long positions
--dir-short-onlyfalseAllow only short positions
--no-pyramidingtrueDisable pyramiding

Strategy inputs

Override strategy input defaults from the command line:

algo run --strategy macrossover --symbols @ES --inputs LenFast=5,LenSlow=50

Multiple 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 simple

The --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 8

The default is 64 workers. Use --parallel 0 for sequential execution.

Symbol specification

The --symbols flag supports flexible syntax:

SyntaxMeaningExample
@ESSingle symbolOne run on E-mini S&P
@ES,@NQComma-separatedSeparate runs per symbol
@ES/@NQSlash-separatedOne run with multiple legs
<metalsPortfolio referenceOne run per symbol in the file
<metals/@NQMixedEach metal paired with @NQ
<metal/<softCartesian productEvery metal x every soft