Phase 4: Advanced Order Management
- Add stop_loss and take_profit fields to Trade class with DB persistence
- Add SL/TP form fields in new trade popup with validation
- Implement SL/TP evaluation in PaperBroker.update()
- Auto-close positions when SL/TP thresholds are crossed
- Emit sltp_triggered events to frontend with notifications
- Add Time-in-Force dropdown (GTC, IOC, FOK) to trade form
- Add persistence for position_sltp tracking across state save/load
- Add unit tests for SL/TP functionality (5 new tests)
- Add Trade class SL/TP field tests (2 new tests)
Also includes Phase 3 manual trading broker hardening:
- Fix broker UI not wired on startup
- Fix cancelled orders vanishing from history
- Fix positions not live-updating P/L
- Fix paper pricing exchange-ambiguity
- Simplify paper trades to single synthetic market
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix market/symbol key mismatch in PythonGenerator.py (6 locations)
causing backtest to use wrong trading pair (BTC/USD vs BTC/USDT)
- Fix backtesting.py to always use default_source for backtest data
- Fix exchange/exchange_name key mismatch in app.py and BrighterTrades.py
causing strategy dialog to show wrong current chart exchange
- Add favicon links to standalone HTML templates
- Add AI strategy dialog template
- Update tests and documentation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix default fee from 0.1 (10%) to 0.001 (0.1%) in Trade class
- Add real-time trade updates via WebSocket trade_update events
- Fetch current market price for market orders instead of using cached price
- Add trade persistence to database with proper schema
- Add execution loop to update trades even without active strategies
- Add frontend handler for trade_update events in communication.js
- Add handleTradeUpdate method in trade.js for live P/L updates
- Add debug file logging for trade update debugging
- Update statistics dashboard and trading HUD templates
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>