CLI Reference
The klawtrade command-line interface provides commands for starting the engine, initializing configuration, and checking system status.
klawtrade start
Starts the trading engine. By default, it reads from config/settings.yaml and runs all active strategies.
klawtrade start [options]Options
| Flag | Description |
|---|---|
--sim | Force simulation mode regardless of config or Alpaca keys. |
-p, --port <number> | Override the dashboard port. Defaults to 8080 or whatever is set in the config file. |
-c, --config <path> | Path to a custom config file. Defaults to config/settings.yaml. |
Examples
# Start with default settings
klawtrade start
# Force simulation mode
klawtrade start --sim
# Use a custom config and port
klawtrade start -c my-config.yaml -p 9090klawtrade init
Runs the interactive setup wizard that creates your config and environment files. If config files already exist, the wizard will ask before overwriting them.
klawtrade init [directory] [options]Options
| Flag | Description |
|---|---|
-q, --quick | Skip the interactive wizard and generate config files with default values. Useful for automated setups or CI environments. |
Examples
# Interactive setup in current directory
klawtrade init
# Quick setup with defaults
klawtrade init --quick
# Initialize in a specific directory
klawtrade init ~/my-trading-projectklawtrade backtest
Runs a historical backtest by downloading market data, replaying it through strategies and the risk manager, and printing performance metrics including Sharpe ratio, win rate, max drawdown, and trade statistics.
klawtrade backtest [options]Options
| Flag | Description |
|---|---|
--start-date <YYYY-MM-DD> | Start date for the backtest period (required). |
--end-date <YYYY-MM-DD> | End date for the backtest period (required). |
--symbols <list> | Comma-separated ticker symbols. Defaults to the watchlist in your config. |
--strategy <name> | Strategy to test: momentum, mean_reversion, or all (default: all). |
--capital <amount> | Starting capital (default: 100000). |
Examples
# Backtest all strategies on default watchlist
klawtrade backtest --start-date 2024-01-01 --end-date 2024-12-31
# Backtest momentum on specific stocks with $50k
klawtrade backtest --start-date 2024-06-01 --end-date 2024-12-31 \
--symbols AAPL,MSFT,NVDA --strategy momentum --capital 50000klawtrade status
Checks if KlawTrade is running by querying the dashboard API. Shows equity, cash, daily P&L, number of open positions, and whether the circuit breaker is active.
klawtrade status [options]Options
| Flag | Description |
|---|---|
-p, --port <number> | Dashboard port to check. Defaults to 8080. |
Examples
# Check status on default port
klawtrade status
# Check status on a different port
klawtrade status -p 9090