What is TradingSpec?
TradingSpec is the single configuration object that completely defines a trading system — what data to use, what strategy to run, and how to execute orders. In notebook development, mode is always "backtest". Paper and live trading run on the platform after you submit your strategy — the same graph runs identically in all modes.
Hierarchy Overview
TradingDataSpec
Defines what data the system consumes.SymbolSourceMap
Maps exchanges to symbols, creating the axis keys used throughout the system:
Key methods:
OHLCVSpec
Currently the primary data source:exchange and market_type can be lists — the driver expands them into concrete specs:
TradingStrategySpec
Wraps the StatefulGraph with metadata:TradingExecutionSpec
Defines how trades are executed:mode is a top-level field on TradingSpec, not on TradingExecutionSpec. In notebook development, always set mode="backtest" directly on TradingSpec.AccountSpec
Each exchange account is defined separately:key property: Returns "{exchange}:{market_type}" (e.g., "binance:futures")
CostModelSpec
Override trading fees per account:Execution Modes
Backtest
- Uses historical data from
starttoend - Simulated execution with CostModelSpec fees
initial_cashrequired per account- No API credentials needed
- The only mode used in notebook cells
Paper
- Uses live/current data from the exchange
- Simulated execution (no real orders placed)
initial_cashoptional (defaults to 10000.0)- No API credentials needed
Paper trading is managed through the dashboard after strategy submission. It cannot be run from notebook cells.
Live
- Uses live data from exchange APIs
- Real order execution
- Requires API credentials
initial_cashis optional — if set, it acts as a capital cap (actual balance must be >= initial_cash)
Live trading is managed through the dashboard after strategy submission. It cannot be run from notebook cells.
Supported Exchanges
Validation
TradingSpec.validate() enforces:
- Mode must be explicitly set (
"backtest","paper", or"live") - Strategy.graph must not be None
- Observations must not be empty
- Live mode: accounts must have credentials,
initial_cashis optional (capital cap if set) - Backtest mode: accounts need observation data at system clock resolution
AccountSpec.__post_init__() validates:
base_currencyis uppercase 3-4 lettersexchange:market_typeis a valid combinationbase_currencyis supported by the exchange/market_typemax_leveragedoesn’t exceed venue maximum
SymbolSourceMap.validate_base_currencies():
- Symbol quote currencies must match account base currencies
- Prevents PnL calculation errors (e.g., USD vs USDT mismatch)
Complete Example
Going to Paper or Live
Paper and live trading are not configured from notebook cells. After backtesting your strategy:- Submit your strategy via the dashboard
- The platform validates and re-runs your backtest for independent verification
- Start a Paper or Live run from the dashboard — the same
StatefulGraphruns without any code changes
Multi-Exchange Example
STATE:binance:futures:*, STATE:gateio:futures:*), enabling venue-specific equity tracking and order execution.
Common Mistakes
Mismatched base_currency
Missing observation for account
initial_cash in live mode
Relationship to Other Concepts
- StatefulGraph:
TradingStrategySpec.graphholds the graph - FIELD Data Principle: Observations define available FIELD sources
- STATE Principle: AccountSpec defines STATE namespaces
- Execution Pipeline: TradingExecutionSpec configures the executor
- Lookback Buffers: Warmup is computed from graph + data specs

