- Remove manual leverage field from automation v2 page since AI now handles leverage automatically
- Fix scalping strategy analysis intervals from 60 minutes to 2 minutes for proper high-frequency trading
- Implement intelligent interval detection based on selected timeframes:
* Scalping: 2 minutes (5m, 3m, or multiple short timeframes)
* Day trading: 5 minutes (1h, 2h timeframes)
* Swing trading: 15 minutes (4h, daily timeframes)
- Fix Drift SDK API calls: replace getTotalPerpPositionValue() with getFreeCollateral()
- Clean up UI by removing manual controls since AI systems handle optimization
- Fix syntax errors in automation service and balance API
- Ensure proper margin calculations using correct Drift Protocol methods
Tested: Scalping strategy now correctly analyzes every 2 minutes instead of 60 minutes
- Fixed unrealized P&L calculation using Drift's built-in methods
- Replaced manual price calculations with official SDK functions
- Total collateral now accurately matches Drift interface (8.04)
- Unrealized P&L shows realistic values instead of inflated amounts
- Color coding already working: green for profits, red for losses
- Account values now sync properly with actual Drift account data
- Fix leverage application in trade execution (was not being applied)
- Fix stop loss orders with proper OrderTriggerCondition.BELOW/ABOVE
- Fix take profit orders with TRIGGER_LIMIT order type
- Add OrderTriggerCondition import from Drift SDK
- Increase minimum stop loss from 0.5% to 3% to prevent cancellation
- Improve error logging for stop loss placement failures
- Add comprehensive risk management parameter validation
- Update order placement logic with proper trigger conditions
All trading functionality now working:
Leverage application (2x, 5x, etc)
Stop loss orders (minimum 3% for stability)
Take profit orders (minimum 1%)
Account balance calculations
Progress tracking and UI enhancements
- Fixed balance calculation: corrected precision factor for Drift scaledBalance (5.69 vs wrong 0,678.76)
- Implemented multi-RPC failover system with 4 endpoints (Helius, Solana official, Alchemy, Ankr)
- Updated automation page with balance sync, leverage-based position sizing, and removed daily trade limits
- Added RPC status monitoring endpoint
- Updated balance and positions APIs to use failover system
- All Drift APIs now working correctly with accurate balance data