diff --git a/src/__pycache__/main_ml.cpython-310.pyc b/src/__pycache__/main_ml.cpython-310.pyc index de623aa..cdbd2c7 100644 Binary files a/src/__pycache__/main_ml.cpython-310.pyc and b/src/__pycache__/main_ml.cpython-310.pyc differ diff --git a/src/main_ml.py b/src/main_ml.py index 73c21ee..eb89e11 100644 --- a/src/main_ml.py +++ b/src/main_ml.py @@ -570,6 +570,24 @@ class MLTradingBot: hold_time_min = hold_time_s / 60 await self.dashboard.record_sell(pair, current_qty, current_price, profit_usd, profit_pct, hold_time_min) + # ALSO record to completed_trades before deletion + completed_trade = { + 'pair': pair, + 'entry_price': buy_price, + 'exit_price': current_price, + 'qty': current_qty, + 'profit_usd': profit_usd, + 'profit_pct': profit_pct, + 'entry_time': self.current_trades[pair]['buy_time'], + 'exit_time': datetime.now().isoformat(), + 'hold_time_min': hold_time_min + } + # Send to dashboard's completed_trades + try: + await self.dashboard.update_state({'completed_trades': [completed_trade]}) + except: + pass + del self.current_trades[pair] logger.info(f'✅ EXIT EXECUTED & RECORDED TO DASHBOARD!') else: