Skip to content

Commit 391269c

Browse files
fix rca: BTCETH is not a valid trading pair on Binance. The correct symbol is ETHBTC
1 parent a167221 commit 391269c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Trading-Automation/trading_automation.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def add_symbol(self, symbol):
340340
return
341341
try:
342342
if symbol not in self.symbols_to_monitor:
343-
# Validate symbol format - support ALLOWED_SYMBOLS including BTCETH
343+
# Validate symbol format - support ALLOWED_SYMBOLS including ETHBTC
344344
if not symbol or not isinstance(symbol, str) or symbol not in ALLOWED_SYMBOLS:
345345
print(f"[WEBSOCKET] ❌ Symbol not in ALLOWED_SYMBOLS: {symbol}")
346346
return
@@ -838,7 +838,7 @@ def update_websocket_symbols():
838838
valid_symbols = [s for s in symbols_to_monitor
839839
if s and isinstance(s, str) and s in ALLOWED_SYMBOLS]
840840

841-
# Limit to maximum 3 symbols for deployment performance (BTCUSDC, ETHUSDC, BTCETH)
841+
# Limit to maximum 3 symbols for deployment performance (BTCUSDC, ETHUSDC, ETHBTC)
842842
valid_symbols = valid_symbols[:3]
843843

844844
if valid_symbols:
@@ -1175,7 +1175,7 @@ def filter(self, record):
11751175
print("[PERFORMANCE] Scheduler delay warnings suppressed")
11761176

11771177
# Add strict symbol filtering - now supports BTC-ETH cross trading
1178-
ALLOWED_SYMBOLS = {'BTCUSDC', 'ETHUSDC', 'BTCETH'}
1178+
ALLOWED_SYMBOLS = {'BTCUSDC', 'ETHUSDC', 'ETHBTC'}
11791179

11801180
def get_trading_status():
11811181
"""Get current trading status summary"""
@@ -2262,9 +2262,9 @@ def buy_with_universal_transfer(symbol, amount=None):
22622262
def determine_trading_pair(from_asset, to_asset):
22632263
"""Determine the correct trading pair and side for cross-asset trading"""
22642264
if from_asset == 'BTC' and to_asset == 'ETH':
2265-
return 'BTCETH', 'SELL' # Sell BTC to get ETH
2265+
return 'ETHBTC', 'BUY' # Buy ETH with BTC (ETH is base, BTC is quote)
22662266
elif from_asset == 'ETH' and to_asset == 'BTC':
2267-
return 'BTCETH', 'BUY' # Buy BTC with ETH
2267+
return 'ETHBTC', 'SELL' # Sell ETH to get BTC
22682268
elif from_asset == 'BTC' and to_asset == 'USDC':
22692269
return 'BTCUSDC', 'SELL'
22702270
elif from_asset == 'USDC' and to_asset == 'BTC':
@@ -2295,15 +2295,15 @@ def cross_asset_trade(from_asset, to_asset, amount, symbol_for_position=None):
22952295
# Quote currency is USDC
22962296
order = client.order_market_buy(symbol=symbol, quoteOrderQty=amount)
22972297
else:
2298-
# For BTCETH, buying BTC with ETH (quote currency is ETH)
2298+
# For ETHBTC, buying ETH with BTC (quote currency is BTC)
22992299
order = client.order_market_buy(symbol=symbol, quoteOrderQty=amount)
23002300
else:
23012301
# Selling from_asset to get to_asset
23022302
if symbol.endswith('USDC'):
23032303
# Base currency being sold
23042304
order = client.order_market_sell(symbol=symbol, quantity=amount)
23052305
else:
2306-
# For BTCETH, selling BTC to get ETH
2306+
# For ETHBTC, selling ETH to get BTC
23072307
order = client.order_market_sell(symbol=symbol, quantity=amount)
23082308

23092309
# Update balances based on executed trade
@@ -2372,7 +2372,7 @@ def buy(symbol, amount=None):
23722372
else:
23732373
print(f"[SKIP] Insufficient USDC balance: {balance['usd']:.2f} < {amount}")
23742374
return None
2375-
elif symbol == 'BTCETH':
2375+
elif symbol == 'ETHBTC':
23762376
# Decide whether to use BTC or ETH to buy the other
23772377
# Strategy: Use whichever asset we have more of (in USD value)
23782378
btc_price = get_latest_price('BTCUSDC')
@@ -2401,7 +2401,7 @@ def buy(symbol, amount=None):
24012401
eth_amount = min_trade_value / eth_price
24022402
return cross_asset_trade('ETH', 'BTC', eth_amount, symbol_for_position=symbol)
24032403
else:
2404-
print(f"[SKIP] Insufficient balance for BTCETH trade. BTC: ${btc_value:.2f}, ETH: ${eth_value:.2f}")
2404+
print(f"[SKIP] Insufficient balance for ETHBTC trade. BTC: ${btc_value:.2f}, ETH: ${eth_value:.2f}")
24052405
return None
24062406
else:
24072407
print(f"[ERROR] Unsupported symbol for cross-asset trading: {symbol}")
@@ -2492,8 +2492,8 @@ def sell(symbol, qty):
24922492
else:
24932493
print(f"[SKIP] Insufficient ETH balance: {balance['eth']:.6f} < {qty}")
24942494
return None, 0, 0
2495-
elif symbol == 'BTCETH':
2496-
# For BTCETH positions, we need to determine if we're holding BTC or ETH
2495+
elif symbol == 'ETHBTC':
2496+
# For ETHBTC positions, we need to determine if we're holding BTC or ETH
24972497
# Check which asset we actually have in our position
24982498
pos = positions.get(symbol, {})
24992499
if not pos:

0 commit comments

Comments
 (0)