refactor: flatten account command to a single balances view
Remove overview/balances/positions subcommands in favor of one `account` command that returns all balances with an `is_dust` flag. Add descriptions to every parser and expose -a/--agent and --doc on all leaf commands for better help discoverability. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -213,39 +213,27 @@ def _render_tui(payload: Any) -> None:
|
||||
print(str(payload))
|
||||
return
|
||||
|
||||
if "overview" in payload:
|
||||
overview = payload.get("overview", {})
|
||||
print(f"\n{_BOLD}{_CYAN} ACCOUNT OVERVIEW {_RESET}")
|
||||
print(f" Total Equity: {_GREEN}{_fmt_number(overview.get('total_equity_usdt', 0))} USDT{_RESET}")
|
||||
print(f" Spot Assets: {_fmt_number(overview.get('spot_asset_count', 0))}")
|
||||
print(f" Positions: {_fmt_number(overview.get('spot_position_count', 0))}")
|
||||
if payload.get("balances"):
|
||||
print()
|
||||
_render_tui({"balances": payload["balances"]})
|
||||
if payload.get("positions"):
|
||||
print()
|
||||
_render_tui({"positions": payload["positions"]})
|
||||
return
|
||||
|
||||
if "balances" in payload:
|
||||
rows = payload["balances"]
|
||||
table_rows: list[list[str]] = []
|
||||
for r in rows:
|
||||
is_dust = r.get("is_dust", False)
|
||||
dust_label = f"{_DIM}dust{_RESET}" if is_dust else ""
|
||||
table_rows.append(
|
||||
[
|
||||
r.get("market_type", ""),
|
||||
r.get("asset", ""),
|
||||
_fmt_number(r.get("free", 0)),
|
||||
_fmt_number(r.get("locked", 0)),
|
||||
_fmt_number(r.get("total", 0)),
|
||||
_fmt_number(r.get("notional_usdt", 0)),
|
||||
dust_label,
|
||||
]
|
||||
)
|
||||
_print_box_table(
|
||||
"BALANCES",
|
||||
["Market", "Asset", "Free", "Locked", "Total", "Notional (USDT)"],
|
||||
["Asset", "Free", "Locked", "Total", "Notional (USDT)", ""],
|
||||
table_rows,
|
||||
aligns=["left", "left", "right", "right", "right", "right"],
|
||||
aligns=["left", "right", "right", "right", "right", "left"],
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user