v0.7.1-recovery: Fix trade recovery from Binance holdings on startup
This commit is contained in:
parent
e8e2568e1d
commit
6a4e7ee15f
|
|
@ -49,6 +49,33 @@ class TradingBotV07:
|
|||
except Exception as e:
|
||||
logger.warning(f" ⚠️ {symbol} history failed: {e}")
|
||||
|
||||
|
||||
# LOAD EXISTING HOLDINGS FROM BINANCE
|
||||
logger.info("[v0.7.1] Recovering existing holdings from Binance...")
|
||||
try:
|
||||
account = self.client.get_account()
|
||||
for b in account['balances']:
|
||||
asset = b['asset']
|
||||
free = float(b['free'])
|
||||
|
||||
if asset in ['BTC', 'ETH', 'BNB', 'XRP', 'SOL', 'ADA', 'DOGE', 'DOT', 'AVAX'] and free > 0.0001:
|
||||
symbol = asset + 'USDT'
|
||||
try:
|
||||
price = self.get_current_price(symbol)
|
||||
if price and price > 0:
|
||||
self.active_trades[symbol] = {
|
||||
'entry_price': price,
|
||||
'qty': free,
|
||||
'entry_time': datetime.now().isoformat()
|
||||
}
|
||||
logger.info(f" ✅ RECOVERED {symbol} {free} @ ${price}")
|
||||
except Exception as e:
|
||||
logger.warning(f" ⚠️ {symbol} recovery error: {e}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Recovery failed: {e}")
|
||||
|
||||
logger.info(f"[v0.7.1] Startup complete. Active trades: {len(self.active_trades)}")
|
||||
|
||||
logger.info(f"[v0.7.1 INIT] Price history loaded. Ready for ±1.5% signals.")
|
||||
|
||||
logger.info("[v0.7 INIT] Coin-Level Contrarian (9 Coins, ±1.5% Thresholds)")
|
||||
|
|
@ -309,7 +336,7 @@ class TradingBotV07:
|
|||
'portfolio_value': round(portfolio_val, 2),
|
||||
'max_trade_usdt': round(self.max_trade_usdt, 2),
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'version': 'v0.7.1-fixed-24h-history'
|
||||
'version': 'v0.7.1-recovery-fix'
|
||||
}, f)
|
||||
os.replace(temp, '/home/marc/bot-deploy/active_trades.json')
|
||||
except:
|
||||
|
|
|
|||
Loading…
Reference in New Issue