Bot auto-update: src/main_ml.py
This commit is contained in:
parent
823aa9b73f
commit
de57afabdb
|
|
@ -107,6 +107,24 @@ class MLTradingBot:
|
|||
self.max_drawdown = 0.0
|
||||
self.min_daily_pnl = 0.0
|
||||
self.starting_capital = 100.0
|
||||
|
||||
# Initialize persistence and load trades
|
||||
init_persistence()
|
||||
self.current_trades, self.completed_trades, self.swaps = load_persistent_trades()
|
||||
|
||||
if self.current_trades:
|
||||
logger.info(f"Loaded {len(self.current_trades)} trades from persistent storage")
|
||||
|
||||
# If portfolio value exists but no trades: recover from Binance
|
||||
portfolio_val = self.binance.get_portfolio_value_usd()
|
||||
if not self.current_trades and portfolio_val > 50:
|
||||
logger.info(f"Portfolio exists ({portfolio_val:.2f}) but no trades - loading from Binance...")
|
||||
binance_trades = load_binance_positions_on_startup()
|
||||
if binance_trades:
|
||||
self.current_trades.update(binance_trades)
|
||||
save_persistent_trades(self.current_trades, self.completed_trades, self.swaps)
|
||||
logger.info(f"Recovered {len(binance_trades)} positions from Binance API")
|
||||
|
||||
self.daily_loss_limit_reached = False
|
||||
|
||||
# Symbol constraints cache
|
||||
|
|
|
|||
Loading…
Reference in New Issue