CLI Reference¶
Complete reference for the tradai command-line interface.
Installation¶
The CLI is installed automatically with the TradAI workspace:
Verify installation:
Global Options¶
| Option | Description |
|---|---|
--help | Show help message |
--install-completion | Install shell completion |
--show-completion | Show completion script |
Service Commands¶
tradai up¶
Start all TradAI services using Docker Compose.
tradai down¶
Stop all TradAI services.
tradai ps¶
Show status of running services.
tradai logs¶
View logs for TradAI services.
Strategy Commands¶
Strategy management and development.
tradai strategy new¶
Create a new strategy from template.
# Basic strategy
tradai strategy new MyStrategy
# ML-enabled strategy
tradai strategy new MyMLStrategy --ml
# With specific exchange
tradai strategy new MyStrategy --exchange binance_futures
Options:
| Option | Description | Default |
|---|---|---|
--ml | Enable FreqAI ML support | false |
--exchange | Target exchange | binance_futures |
--output-dir | Output directory | ./strategies |
tradai strategy wizard¶
Interactive wizard for creating a new strategy with guided prompts.
tradai strategy list¶
List available strategies from backend service.
tradai strategy info¶
Get detailed information about a strategy.
tradai strategy lint¶
Lint a strategy for common issues.
tradai strategy version¶
Show current version of a strategy in MLflow registry.
tradai strategy versions¶
List all versions of a strategy with their stages.
tradai strategy set-version¶
Promote a strategy version to a stage (Staging, Production).
# Stage for validation
tradai strategy set-version PascalStrategy 3 --stage Staging
# Promote to production
tradai strategy set-version PascalStrategy 3 --stage Production
tradai strategy optimize¶
Optimize strategy parameters using Freqtrade hyperopt.
tradai strategy optimize PascalStrategy \
--epochs 100 \
--spaces buy sell \
--timerange 20240101-20240301
Options:
| Option | Description | Default |
|---|---|---|
--epochs, -e | Number of optimization epochs | 100 |
--spaces | Spaces to optimize (buy, sell, roi, stoploss) | buy sell |
--timerange | Date range for optimization | Last 90 days |
--jobs, -j | Parallel jobs | CPU count |
tradai strategy optimize-preset¶
Run optimization with preset configuration.
# Quick optimization
tradai strategy optimize-preset PascalStrategy quick
# Standard optimization
tradai strategy optimize-preset PascalStrategy standard
# Thorough optimization
tradai strategy optimize-preset PascalStrategy thorough
tradai strategy optimize-results¶
List recent optimization runs from MLflow.
tradai strategy optimize-results
# Filter by strategy
tradai strategy optimize-results --strategy PascalStrategy
tradai strategy optuna¶
Run Optuna ML hyperparameter optimization for FreqAI models.
tradai strategy bump¶
Bump strategy version with optional changelog entry.
# Patch bump (1.0.0 -> 1.0.1)
tradai strategy bump PascalStrategy patch
# Minor bump (1.0.0 -> 1.1.0)
tradai strategy bump PascalStrategy minor
# Major bump (1.0.0 -> 2.0.0)
tradai strategy bump PascalStrategy major
# With changelog message
tradai strategy bump PascalStrategy patch -m "Fixed entry signal logic"
tradai strategy changelog¶
View strategy changelog.
Backtest Commands¶
Backtest visualization and analysis.
tradai backtest quick¶
Quick backtest with minimal output for rapid iteration.
# Basic quick backtest
tradai backtest quick PascalStrategy
# With options
tradai backtest quick PascalStrategy \
--period 30d \
--symbol BTC/USDT:USDT \
--timeframe 1h
# Local mode (no backend required)
tradai backtest quick PascalStrategy --local
Options:
| Option | Description | Default |
|---|---|---|
--period, -p | Backtest period (e.g., 7d, 30d, 3m) | 30d |
--symbol, -s | Trading symbol | BTC/USDT:USDT |
--timeframe, -t | Candle timeframe | 1h |
--stake | Stake amount per trade | 1000.0 |
--local | Run locally without backend | false |
--no-wait | Return job ID immediately | false |
tradai backtest list¶
List recent backtest jobs.
# List all
tradai backtest list
# Filter by status
tradai backtest list --status completed
tradai backtest list --status failed
# Limit results
tradai backtest list --limit 10
tradai backtest show¶
Show backtest results with ASCII visualizations.
tradai backtest show <job_id>
# With equity curve
tradai backtest show <job_id> --equity
# With trade table
tradai backtest show <job_id> --trades
tradai backtest compare¶
Compare two backtest runs side by side.
tradai backtest report¶
Generate interactive HTML report for a backtest.
tradai backtest report <job_id>
# Custom output path
tradai backtest report <job_id> --output ./reports/my-report.html
# Auto-open in browser
tradai backtest report <job_id> --open
tradai backtest trades¶
Export trade log from a backtest run.
# Export to CSV
tradai backtest trades <job_id> --format csv --output trades.csv
# Export to JSON
tradai backtest trades <job_id> --format json --output trades.json
Data Commands¶
Data collection and management.
tradai data sync¶
Sync OHLCV data from exchange to storage.
# Sync specific symbol
tradai data sync BTC/USDT:USDT --days 90
# Sync with date range
tradai data sync BTC/USDT:USDT \
--start 2024-01-01 \
--end 2024-06-01
# Sync multiple symbols
tradai data sync BTC/USDT:USDT ETH/USDT:USDT SOL/USDT:USDT
# Sync all configured symbols
tradai data sync --all
Options:
| Option | Description | Default |
|---|---|---|
--days | Days of history to sync | 30 |
--start | Start date (YYYY-MM-DD) | - |
--end | End date (YYYY-MM-DD) | Today |
--timeframe | Candle timeframe | 1h |
--all | Sync all configured symbols | false |
tradai data list-symbols¶
List available trading symbols from exchange.
tradai data list-symbols
# Filter by quote currency
tradai data list-symbols --quote USDT
# Search
tradai data list-symbols --search BTC
tradai data check-freshness¶
Check data freshness for given symbols.
tradai data check-freshness BTC/USDT:USDT ETH/USDT:USDT
# With stale threshold
tradai data check-freshness BTC/USDT:USDT --stale-hours 24
tradai data preview¶
Preview recent OHLCV data for a symbol.
tradai data health¶
Check data collection service health status.
Deploy Commands¶
Strategy deployment to AWS.
tradai deploy strategy¶
Deploy a strategy to AWS ECS.
# Deploy to staging
tradai deploy strategy PascalStrategy --env staging
# Deploy to production
tradai deploy strategy PascalStrategy --env production
# Deploy specific version
tradai deploy strategy PascalStrategy --version 3 --env production
# Dry run (preview only)
tradai deploy strategy PascalStrategy --env staging --dry-run
Options:
| Option | Description | Default |
|---|---|---|
--env | Target environment | Required |
--version | Strategy version | Latest |
--dry-run | Preview without deploying | false |
--skip-validation | Skip pre-deploy checks | false |
tradai deploy status¶
Show deployment status.
# All deployments
tradai deploy status
# Specific strategy
tradai deploy status PascalStrategy
# Specific environment
tradai deploy status --env production
tradai deploy logs¶
View deployment logs from CloudWatch.
tradai deploy logs PascalStrategy --env production
# Follow logs
tradai deploy logs PascalStrategy --env production --follow
# Last N lines
tradai deploy logs PascalStrategy --env production --tail 100
tradai deploy rollback¶
Rollback a strategy to previous version.
tradai deploy rollback PascalStrategy --env production
# Rollback to specific version
tradai deploy rollback PascalStrategy --env production --version 2
tradai deploy history¶
Show deployment history for a strategy.
tradai deploy history PascalStrategy
# With environment filter
tradai deploy history PascalStrategy --env production
tradai deploy diff¶
Compare strategy deployments between environments.
tradai deploy emergency-close¶
Emergency stop a running strategy (closes all positions).
tradai deploy emergency-close PascalStrategy --env production
# With confirmation skip
tradai deploy emergency-close PascalStrategy --env production --yes
tradai deploy restart¶
Restart a stopped or unhealthy strategy.
Monitor Commands¶
Monitor running trading strategies.
tradai monitor status¶
Show live status of running strategies.
tradai monitor status
# Watch mode with auto-refresh
tradai monitor status --watch
tradai monitor status --watch --interval 10
# JSON output
tradai monitor status --json
Options:
| Option | Description | Default |
|---|---|---|
--watch, -w | Auto-refresh display | false |
--interval, -i | Refresh interval (seconds) | 5 |
--json | Output as JSON | false |
tradai monitor stale¶
Show strategies with stale heartbeats (potential health issues).
tradai monitor stale
# Custom threshold
tradai monitor stale --threshold 10
# JSON output
tradai monitor stale --json
tradai monitor get¶
Get detailed status of a specific strategy.
tradai monitor pnl¶
Show P&L for running strategies.
# All strategies
tradai monitor pnl
# Specific strategy
tradai monitor pnl pascal-v1
# Watch mode
tradai monitor pnl --watch
# JSON output
tradai monitor pnl --json
tradai monitor trades¶
Show recent trades from running strategies.
tradai monitor trades pascal-v1
# Limit results
tradai monitor trades pascal-v1 --limit 50
# JSON output
tradai monitor trades pascal-v1 --json
tradai monitor compare¶
Compare live performance vs backtest expectations.
tradai monitor compare pascal-v1
# Custom deviation threshold
tradai monitor compare pascal-v1 --threshold 15
# JSON output
tradai monitor compare pascal-v1 --json
Shows side-by-side comparison of live metrics against the latest Production backtest from MLflow. Highlights significant deviations.
tradai monitor health¶
Show detailed health status of running strategies.
# All strategies
tradai monitor health
# Specific strategy
tradai monitor health pascal-v1
# Custom stale threshold
tradai monitor health --stale 10
# JSON output
tradai monitor health --json
Monitor Alerts Commands¶
Alert monitoring and webhook testing.
tradai monitor alerts list¶
List recent alerts from DynamoDB.
tradai monitor alerts list
# Filter by severity
tradai monitor alerts list --severity critical
# Filter by service
tradai monitor alerts list --service strategy-service
# Limit results
tradai monitor alerts list --limit 10
tradai monitor alerts history¶
Show alert history for a time range.
# Last 24 hours (default)
tradai monitor alerts history --start 24h
# Last 7 days
tradai monitor alerts history --start 7d
# Date range
tradai monitor alerts history --start 2024-01-01 --end 2024-01-02
# Filter by severity
tradai monitor alerts history --start 7d --severity error
tradai monitor alerts get¶
Get detailed view of a specific alert.
tradai monitor alerts test-slack¶
Send a test alert to Slack.
tradai monitor alerts test-slack --url https://hooks.slack.com/...
# With severity
tradai monitor alerts test-slack --severity critical
# Using environment variable
SLACK_WEBHOOK_URL=https://... tradai monitor alerts test-slack
tradai monitor alerts test-discord¶
Send a test alert to Discord.
tradai monitor alerts test-discord --url https://discord.com/api/webhooks/...
# With severity
tradai monitor alerts test-discord --severity error
# Using environment variable
DISCORD_WEBHOOK_URL=https://... tradai monitor alerts test-discord
Monitor Queue Commands¶
Monitor and manage backtest job queues and DLQs.
tradai monitor queue status¶
Show queue and DLQ message counts.
tradai monitor queue inspect¶
View DLQ message details.
# Show all DLQ messages
tradai monitor queue inspect
# Limit results
tradai monitor queue inspect --max 5
# Specific message
tradai monitor queue inspect MSG-123
# JSON output
tradai monitor queue inspect --json
tradai monitor queue replay¶
Replay messages from DLQ to main queue.
# Replay specific message
tradai monitor queue replay MSG-123
# Replay all messages
tradai monitor queue replay --all
# Dry run
tradai monitor queue replay --all --dry-run
Validate Commands¶
Validation commands for strategies and data.
tradai validate strategy¶
Run pre-flight validation checks on a strategy.
tradai validate strategy PascalStrategy
# Verbose output
tradai validate strategy PascalStrategy --verbose
tradai validate config¶
Validate a strategy configuration file.
Validate Dryrun Commands¶
Dry-run validation for strategy deployments.
tradai validate dryrun run¶
Run full validation suite for a dry-run deployment.
tradai validate dryrun run pascal-v2 --days 7
# Custom output
tradai validate dryrun run pascal-v2 --days 7 --output validation.md
Validation Thresholds:
| Metric | Default | Description |
|---|---|---|
uptime_percentage | 95% | Minimum heartbeat uptime |
max_gap_seconds | 300s | Maximum gap between heartbeats |
candle_completeness | 98% | Minimum data completeness |
tradai validate dryrun heartbeats¶
Validate heartbeat uptime for a strategy.
tradai validate dryrun candles¶
Validate candle data completeness.
tradai validate dryrun candles pascal-v2 --symbol BTC/USDT:USDT
tradai validate dryrun candles pascal-v2 --symbol BTC/USDT:USDT --days 7
tradai validate dryrun signoff¶
Generate sign-off checklist for dry-run validation.
tradai validate dryrun signoff pascal-v2
tradai validate dryrun signoff pascal-v2 --output signoff.md
Validate Golive Commands¶
Go-live infrastructure validation before production deployment.
tradai validate golive verify¶
Run full infrastructure verification.
tradai validate golive verify --env prod
tradai validate golive verify --env staging --output report.md
tradai validate golive alarms¶
Verify CloudWatch alarms are configured and enabled.
Expected Alarms: - {project}-{env}-backend-unhealthy - {project}-{env}-strategy-service-unhealthy - {project}-{env}-data-collection-unhealthy - {project}-{env}-orphan-scanner-errors - {project}-{env}-health-check-errors - {project}-{env}-trading-heartbeat-check-errors - {project}-{env}-drift-monitor-errors - {project}-{env}-retraining-scheduler-errors
tradai validate golive alerts¶
Verify SNS alerting is working.
tradai validate golive lambdas¶
Verify Lambda health checks are running.
Expected Lambdas: - {project}-orphan-scanner-{env} - {project}-health-check-{env} - {project}-trading-heartbeat-check-{env} - {project}-drift-monitor-{env} - {project}-retraining-scheduler-{env}
Doctor Commands¶
System diagnostics and health checks.
tradai doctor check¶
Run full system diagnostics.
tradai doctor deps¶
Check Python dependencies status.
tradai doctor services¶
Check service connectivity.
Auth Commands¶
Authentication management.
tradai auth login¶
Authenticate with TradAI services.
tradai auth logout¶
Clear authentication tokens.
tradai auth status¶
Show current authentication status.
tradai auth whoami¶
Display current user information from JWT token.
Shows decoded claims from the ID token including email, username, and Cognito groups.
tradai auth config¶
Initialize or show authentication configuration.
# Initialize new config file
tradai auth config
# Show current configuration
tradai auth config --show
Creates ~/.tradai/config.yaml with environment configuration template.
tradai auth environments¶
List all configured environments and their authentication status.
Shows which environments have valid stored tokens.
A/B Test Commands¶
A/B testing for strategy versions.
tradai ab-test create¶
Create a new A/B test (champion vs challenger).
tradai ab-test status¶
Show status of active A/B tests.
tradai ab-test evaluate¶
Evaluate A/B test results and get recommendation.
tradai ab-test conclude¶
Conclude an A/B test (promote or rollback).
# Promote challenger
tradai ab-test conclude <test_id> --promote
# Keep champion
tradai ab-test conclude <test_id> --rollback
Indicator Commands¶
Indicator testing and exploration.
tradai indicator test¶
Test an indicator expression interactively.
tradai indicator test "ta.EMA(close, 20)"
# With specific symbol and timeframe
tradai indicator test "ta.RSI(close, 14)" \
--symbol BTC/USDT:USDT \
--timeframe 1h
tradai indicator list¶
List available technical indicators.
tradai indicator list
# Filter by category
tradai indicator list --category trend
tradai indicator list --category momentum
Version Command¶
tradai version¶
Show TradAI CLI version.
Environment Variables¶
| Variable | Description | Default |
|---|---|---|
TRADAI_BACKEND_URL | Backend service URL | http://localhost:8000 |
TRADAI_STRATEGY_URL | Strategy service URL | http://localhost:8003 |
TRADAI_DATA_URL | Data collection URL | http://localhost:8002 |
TRADAI_ENV | Default environment | development |
TRADAI_LOG_LEVEL | Log verbosity | INFO |
Shell Completion¶
Install shell completion for better CLI experience:
# Bash
tradai --install-completion bash
# Zsh
tradai --install-completion zsh
# Fish
tradai --install-completion fish
See Also¶
Quickstarts:
- Your First Backtest - Step-by-step tutorial
SDK Reference:
- tradai-common - Common utilities
- tradai-data - Data layer
- tradai-strategy - Strategy framework
Services:
- Backend Service - API endpoints for backtesting
- Strategy Service - Strategy configuration and MLflow
- Data Collection - Data fetching and storage
Lambdas:
- Lambda Functions - Serverless function reference
Architecture:
- Architecture Overview - System diagrams and patterns
- Runbooks - Operations guides