Key fixes:
- ExchangeInterface: Remove stale entries before creating new exchange connections
- LiveBroker: Optimize get_total_equity() to price only top 10 assets (was hanging on 462 testnet assets)
- LiveBroker: Add fiat currency skip list to avoid failed price lookups
- PythonGenerator: Fix market symbol regex to handle 2-5 char symbols (BTC/USDT)
New features:
- LiveStrategyInstance: Full live trading strategy execution
- Circuit breaker and position limits for live trading safety
- Restart-safe order reconciliation via client order IDs
Verified working:
- Live strategy starts on Binance testnet
- Orders placed and filled successfully
- Execution loop runs with active strategies
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1. Paper equity calculation (High):
- get_balance() now correctly includes position value (size * current_price)
- Previously only added unrealized_pnl, missing position principal
2. Buy affordability checks (High):
- place_order() now uses execution price including slippage for market orders
- Uses limit price for limit orders instead of current price
- Prevents orders that would drive cash negative
3. ExchangeInterface price stubs (High):
- get_trade_executed_price() now handles order_price=0.0 (market orders)
- Falls back to current price or entry price when order_price is zero
4. Determinism hash strengthening (Medium):
- Hash now includes full trade sequence with individual trade details
- Added test for different trade sequences with same totals
5. Live mode consistency (Medium):
- Factory now falls back to paper trading with warning instead of raising
- Consistent behavior between factory.py and Strategies.py
Added test: test_paper_broker_equity_calculation to verify fix#1
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 5 - Live Trading (stub implementation):
- Create LiveBroker stub with NotImplementedError for all methods
- Document required exchange API integration points
- Add testnet flag for safety
Phase 6 - Observability:
- Add structured logging with StructuredFormatter and ColoredFormatter
- Create TradingLogger for trading-specific log entries
- Implement health check system with HealthCheck class
- Add default health checks for database, exchange, memory
- Create health_endpoint() for monitoring integration
The LiveBroker is a stub that needs exchange API integration
for production use. All other trading modes (backtest, paper)
are fully functional.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create PaperStrategyInstance extending StrategyInstance
- Integrate PaperBroker for simulated order execution
- Add trade_order() method translating Blockly calls to broker
- Add mode selection in Strategies.create_strategy_instance()
- Update execute_strategy() to support paper/backtest/live modes
- Include comprehensive tests for paper trading functionality
Paper trading now works with:
- Market and limit orders
- Position tracking with P&L
- Balance management
- Trade history
- Reset functionality
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix deprecated datetime.utcfromtimestamp() in shared_utilities.py
- Create BacktestResult schema with locked structure
- Add TradeResult and BacktestMetrics dataclasses
- Implement determinism hash for verifying reproducible results
- Add comprehensive tests for result schema and determinism
The BacktestResult schema ensures consistent output format and
provides methods to verify that same inputs produce same results.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create brokers package with unified trading interface
- BaseBroker: Abstract base class defining broker contract
- BacktestBroker: Wraps Backtrader for backtesting mode
- PaperBroker: Simulated order execution for paper trading
- Factory function to create broker based on trading mode
- Comprehensive test suite for broker functionality
The broker abstraction enables strategies to work identically
across backtest, paper, and live trading modes.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix set_new_candle() to update cached candle instead of raising
- Fix trades.update() type mismatch: pass {symbol: price} dict
- Fix StrategyInstance.trades collision: rename list to trade_history
- Add missing ExchangeInterface methods for trade status/qty/price
- Add get_user_balance stub for paper trading
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Security: Move API keys to environment variables in config.py
- Portability: Use cross-platform path resolution for DB_FILE
- Add config.example.py template for developers
- Fix Windows path in ExchangeInterface.get_public_exchanges()
- Add cached_last_candle attribute to Candles class
- Add pytest configuration (pytest.ini, conftest.py)
- Fix test imports for DataCache_v3
- Include identity compatibility layer (user_name/user_id resolution)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>