Compare commits
No commits in common. "e67077c0935a6136981b6ddeb29d4844637b11bb" and "8d28a7e2fc75b8cbf357dc0c5f7a68a7458cedcf" have entirely different histories.
e67077c093
...
8d28a7e2fc
Binary file not shown.
|
|
@ -899,50 +899,6 @@ class MLTradingBot:
|
||||||
"""Main bot loop"""
|
"""Main bot loop"""
|
||||||
logger.info('🤖 BOT STARTED (V5 - SUSTAINABLE)')
|
logger.info('🤖 BOT STARTED (V5 - SUSTAINABLE)')
|
||||||
|
|
||||||
# Auto-recover open positions from Binance on restart
|
|
||||||
logger.info('📥 Recovering trades from Binance...')
|
|
||||||
try:
|
|
||||||
for pair in ['BTCUSDT', 'ETHUSDT', 'SOLUSDT', 'BNBUSDT', 'XRPUSDT']:
|
|
||||||
orders = self.binance._client.get_open_orders(symbol=pair)
|
|
||||||
if orders:
|
|
||||||
o = orders[0]
|
|
||||||
self.current_trades[pair] = {
|
|
||||||
'qty': float(o['origQty']),
|
|
||||||
'buy_price': float(o['price']),
|
|
||||||
'buy_time': ''.join([str(i) for i in range(10)]),
|
|
||||||
'order_id': o['orderId'],
|
|
||||||
'peak_profit': 0.0
|
|
||||||
}
|
|
||||||
logger.info(f' ✅ Recovered {pair}: {o[origQty]} @ {o[price]}')
|
|
||||||
except Exception as e:
|
|
||||||
logger.debug(f'Recovery scan: {e}')
|
|
||||||
|
|
||||||
logger.info(f'✅ Recovered {len(self.current_trades)} trades from Binance')
|
|
||||||
|
|
||||||
# STARTUP: Load open orders from Binance so Bot knows its positions
|
|
||||||
logger.info('📥 Loading open positions from Binance...')
|
|
||||||
try:
|
|
||||||
account = await self.binance.get_balance()
|
|
||||||
for pair in ['BTCUSDT', 'ETHUSDT', 'SOLUSDT', 'BNBUSDT', 'XRPUSDT']:
|
|
||||||
try:
|
|
||||||
orders = await self.binance.get_open_orders(pair)
|
|
||||||
if orders:
|
|
||||||
order = orders[0]
|
|
||||||
self.current_trades[pair] = {
|
|
||||||
'qty': float(order['origQty']),
|
|
||||||
'buy_price': float(order['price']),
|
|
||||||
'buy_time': datetime.fromtimestamp(order['time']/1000).isoformat(),
|
|
||||||
'order_id': order['orderId'],
|
|
||||||
'peak_profit': 0.0
|
|
||||||
}
|
|
||||||
logger.info(f' ✅ Loaded {pair}: {order[origQty]} @ ')
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f'Could not load Binance positions: {e}')
|
|
||||||
|
|
||||||
logger.info(f'✅ Startup complete: {len(self.current_trades)} positions loaded from Binance')
|
|
||||||
|
|
||||||
# Create trigger file location
|
# Create trigger file location
|
||||||
trigger_file = '/tmp/bot_liquidate_trigger'
|
trigger_file = '/tmp/bot_liquidate_trigger'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue