fix: /balance показывает эквивалент каждой монеты и итого в USDC
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -291,14 +291,34 @@ def _send_balance(cfg):
|
||||
spot = SpotExecutor(cfg.exchange, leverage=cfg.risk.leverage)
|
||||
spot._ensure_markets()
|
||||
b = spot.exchange.fetch_balance()
|
||||
lines = ["\U0001f4b0 <b>Баланс на бирже</b>", ""]
|
||||
for coin in ["USDC", "USDT", "BTC", "ETH", "SOL"]:
|
||||
|
||||
# Collect balances and convert to USDC
|
||||
total_usdc = 0.0
|
||||
coin_lines = []
|
||||
for coin in ["USDC", "USDT", "BTC", "ETH", "SOL", "AVAX", "LINK", "XRP"]:
|
||||
free = float(b.get(coin, {}).get("free", 0) or 0)
|
||||
total = float(b.get(coin, {}).get("total", 0) or 0)
|
||||
if total > 0.0001:
|
||||
locked = total - free
|
||||
lock_str = f" (заблокировано: {locked:.6f})" if locked > 0.0001 else ""
|
||||
lines.append(f" <b>{coin}:</b> {free:.6f}{lock_str}")
|
||||
if total < 0.0001:
|
||||
continue
|
||||
# Convert to USDC
|
||||
if coin == "USDC":
|
||||
val_usdc = total
|
||||
elif coin == "USDT":
|
||||
val_usdc = total # ~1:1
|
||||
else:
|
||||
price = spot.get_price(f"{coin}/USDC")
|
||||
val_usdc = total * price if price else 0
|
||||
total_usdc += val_usdc
|
||||
locked = total - free
|
||||
lock_str = f" (locked: {locked:.6f})" if locked > 0.0001 else ""
|
||||
coin_lines.append(f" {coin}: {free:.6f}{lock_str}"
|
||||
f" ≈ ${val_usdc:,.2f}")
|
||||
|
||||
lines = ["\U0001f4b0 <b>Баланс на бирже</b>", ""]
|
||||
lines.extend(coin_lines)
|
||||
lines.append("")
|
||||
lines.append(f" <b>Итого: ${total_usdc:,.2f}</b>")
|
||||
|
||||
from .notify import send_telegram
|
||||
send_telegram(cfg.telegram, "\n".join(lines))
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user