-
Notifications
You must be signed in to change notification settings - Fork 0
Using main.py CLI
The main.py command-line interface is the primary way to interact with AutoTrader-AgentEdge for paper trading operations.
Status: β Fully Functional (as of October 23, 2025) Purpose: Unified terminal interface for all trading operations
Test the VoterAgent with live market data.
python main.py test-voterWhat it does:
- Initializes VoterAgent with production parameters
- Fetches 60 days of AAPL market data
- Calculates MACD and RSI indicators
- Generates trading decision with confidence
- Displays component analysis
Example Output:
π€ Testing Production VoterAgent...
β
VoterAgent configured:
MACD: (13/34/8)
RSI: 14 period, 30/70 levels
Fetching AAPL market data...
β
Loaded 42 data points
Price range: $226.79 - $262.77
π Trading Decision:
Action: BUY (Confidence: 65.0%)
Reasoning: Weak signal: Only MACD signals BUY
Current Price: $258.45
π§ Component Analysis:
MACD: BUY (Histogram: 0.111064)
RSI: HOLD (Value: 51.6)
Check current paper trading positions and account status.
python main.py check-positionsRequirements: Alpaca paper trading credentials in config.json
What it does:
- Connects to Alpaca paper trading account
- Fetches account overview (buying power, portfolio value, cash)
- Lists all open positions with P&L
- Shows recent orders
Example Output:
π Checking Paper Trading Positions...
π Account Overview:
Status: ACTIVE
Buying Power: $90,800.04
Portfolio Value: $100,211.33
Cash: $90,800.04
π Current Positions (1):
SPY: 14.0 shares @ $657.60
Market Value: $9,411.29 | P&L: $+204.96 (+2.2%)
π° Total Position Value: $9,411.29
π Recent Orders (2):
SPY: SELL 7.0 @ LIMIT
Status: NEW
Run full trading cycle check and execute updates as needed.
python main.py paper-trade [SYMBOL]Arguments:
-
SYMBOL(optional): Focus on specific symbol (e.g., SPY)
What it does:
- Fetches remote broker state (source of truth)
- Reconciles local vs remote state
- Reviews positions and calculates stop adjustments
- Re-evaluates losing positions using VoterAgent
- Executes stop updates for profitable positions
- Closes positions if VoterAgent signals SELL with >60% confidence
- Updates local state
Example Output:
π Paper Trading System Check & Update
============================================================
π§ Initializing Trading Infrastructure...
1οΈβ£ Fetching Remote Broker State...
π° Portfolio Value: $100,211.01
π΅ Available Cash: $90,800.04
π Active Positions: 1
π Open Orders: 2
2οΈβ£ Reconciling Local vs Remote State...
π Updating 1 discrepancies:
π΄ UNKNOWN_POSITION: SPY - NEEDS_HUMAN_REVIEW
3οΈβ£ Reviewing Positions and Executing Updates...
π SPY:
Quantity: 14 shares
Entry: $657.60
Current: $672.21
P&L: $+14.62 (+2.2%)
5οΈβ£ Updating Local State...
πΎ Local state synchronized with all updates
π Trading Cycle Summary:
π Active Positions: 1
π Stop Adjustments: 0
π Losing Positions Reviewed: 0
β οΈ State Discrepancies Fixed: 1
β
Actions Executed: 0
π€ No actions required this cycle
Generate performance analysis reports.
python main.py analysisWhat it does:
- Runs advanced backtesting analysis
- Generates performance metrics
- Creates visualization reports
Create config/config.json:
{
"POLYGON_IO": "your_polygon_key",
"ALPHA_VANTAGE_KEY": "your_av_key",
"ALPACA_PAPER_API_KEY": "your_alpaca_key",
"ALPACA_PAPER_SECRET": "your_alpaca_secret",
"ALPACA_ENDPOINT": "https://paper-api.alpaca.markets/v2"
}| Command | Requires |
|---|---|
test-voter |
POLYGON_IO or ALPHA_VANTAGE_KEY |
check-positions |
ALPACA_PAPER_API_KEY + SECRET |
paper-trade |
All of the above |
analysis |
Market data keys |
# Make sure you're in the repo root
cd /path/to/AutoTrader-AgentEdge
# Run with python explicitly
python main.py test-voterβ Error: Alpaca paper API credentials required
Solution: Add Alpaca credentials to config/config.json
β Insufficient market data (35 < 42)
Solution: VoterAgent requires at least 42 data points for reliable MACD/RSI calculations. Try a different symbol or check your market data API keys.
If you see import errors, ensure dependencies are installed:
pip install -e .Run paper trading checks on a schedule:
# Morning check (9:20 AM)
python main.py paper-trade SPY
# Evening check (3:50 PM)
python main.py paper-trade SPY# Check different positions
python main.py paper-trade SPY
python main.py paper-trade QQQ
python main.py paper-trade AAPLThe main.py CLI is designed for cost efficiency:
- API Calls: ~10-15 per full trading cycle
- Caching: 85%+ cache hit rate reduces API usage
- Batching: Multiple operations in single cycle
- GTC Orders: Broker execution reduces monitoring
This is 90% fewer API calls compared to reactive trading systems.
- VoterAgent Strategy: Understand the trading logic
- Paper Trading: Safe testing workflow
- Position Management: Track and reconcile positions
Fully Functional: October 23, 2025 | Part of Issue #327