The CLI interface provides a command-line tool for interacting with the Quantum Trader system. It handles market data processing, trading decisions, and system monitoring through a multi-agent architecture.
python -m src.cli.cli_interface --symbols SYMBOL1 SYMBOL2 ... --mode MODE
--symbols
: List of stock symbols to trade (e.g., AAPL MSFT GOOGL)--mode
: Trading mode, either 'paper' or 'live' (default: paper)
Before starting the system, ensure:
- Interactive Brokers TWS or IB Gateway is running
- API connections are enabled in TWS/Gateway
- Socket port (default: 7497) is correctly configured
- Auto-restart is enabled in TWS/Gateway
- 'Read-Only API' is disabled in TWS/Gateway configuration
python -m src.cli.cli_interface --symbols AAPL MSFT GOOGL --mode paper
The system will:
- Check all prerequisites
- Connect to Interactive Brokers
- Initialize the trading swarm
- Begin market data processing
- Start autonomous trading operations
The system processes market data with:
- Real-time price updates
- Volume tracking
- High/low price monitoring
- Synchronized data management
The system operates through specialized agents:
-
Technical Analysis Agent
- Analyzes market data using technical indicators
- Provides technical-based trading signals
-
Sentiment Analysis Agent
- Analyzes market sentiment
- Provides sentiment-based signals
-
Risk Management Agent
- Monitors position sizes and exposure
- Enforces risk limits
-
Trade Execution Agent
- Handles order placement
- Manages trade execution
The system provides detailed logging of:
- Connection status
- Market data updates
- Trading decisions
- Risk management actions
- System status
Example output:
2024-11-10 18:24:20,523 - __main__ - INFO - === Quantum Trader Starting ===
2024-11-10 18:24:20,523 - __main__ - INFO - Mode: paper
2024-11-10 18:24:20,523 - __main__ - INFO - Symbols: ['AAPL', 'MSFT', 'GOOGL']
...
The system handles various error conditions:
- Connection issues
- Market data problems
- Trading errors
- System failures
Error messages include:
- Clear error descriptions
- Relevant context
- Suggested solutions
The system uses a YAML configuration file (src/config/config.yaml
) for:
- API settings
- Risk parameters
- Trading rules
- System behavior
Example configuration:
api:
tws_endpoint: "127.0.0.1"
port: 7497
risk_management:
position_limits:
max_position_size: 100
loss_limits:
daily_loss_limit: 1000
agent_system:
update_interval: 60
- Regular price updates for each symbol
- Synchronized timestamp, price, and volume data
- Proper handling of market hours and data delays
- Risk-based trade filtering
- Position size limits enforcement
- Trade rejection on risk limit violations
- Active: System is running and processing data
- Warning: System encounters non-critical issues
- Error: System encounters critical problems
- Shutdown: System is stopping operations
Common issues and solutions:
-
Connection Problems
- Verify TWS/Gateway is running
- Check API connection settings
- Confirm port configuration
-
Market Data Issues
- Verify market data subscriptions
- Check symbol validity
- Confirm market hours
-
Trading Issues
- Check risk limits
- Verify account permissions
- Confirm trading hours
To stop the system:
- Press Ctrl+C for graceful shutdown
- System will:
- Close market data connections
- Cancel pending orders (if any)
- Disconnect from Interactive Brokers
- Save system state