"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(cli): render broker_sdk order rows and strip stringified SDK enums
Nick Stavros2fc29483f85a
diff --git a/agent/cli/_legacy.py b/agent/cli/_legacy.pyindex 331b5f4c8..e90a2b889 100644--- a/agent/cli/_legacy.py+++ b/agent/cli/_legacy.py@@ -4235,6 +4235,21 @@ def _print_connector_account_mapping(return EXIT_SUCCESS+def _enum_text(value: Any) -> str:+ """Render ``OrderSide.BUY``-style enum reprs as ``BUY``.++ broker_sdk connectors stringify SDK enums, so the raw repr reaches the+ table. Only strips when the prefix looks like a CamelCase class name (it+ must contain a lowercase letter), so ticker symbols such as ``BRK.B`` and+ decimal values are left alone.+ """+ text = str(value or "")+ match = re.fullmatch(r"([A-Z][A-Za-z0-9_]*)\.([A-Z][A-Z0-9_]*)", text)+ if match and any(ch.islower() for ch in match.group(1)):+ return match.group(2)+ return text++def _print_connector_account(result: dict[str, Any]) -> int:accounts = ", ".join(result.get("accounts", [])) or "(none)"rows = result.get("summary", [])@@ -4439,15 +4454,18 @@ def cmd_connector_orders(for row in orders:contract = row.get("contract") or {}order = row.get("order") or row- order_status = row.get("status") or {}+ # IBKR nests status as ``{"status": {"status": ...}}``; broker_sdk+ # connectors (Alpaca, …) return it as a plain string on the flat row.+ raw_status = row.get("status")+ status_text = raw_status.get("status") if isinstance(raw_status, dict) else raw_statustable.add_row(str(order.get("account") or ""),- str(contract.get("local_symbol") or contract.get("symbol") or ""),- str(order.get("action") or ""),- str(order.get("order_type") or ""),- str(order.get("total_quantity") or ""),+ str(contract.get("local_symbol") or contract.get("symbol") or order.get("symbol") or ""),+ _enum_text(order.get("action") or order.get("side") or ""),+ _enum_text(order.get("order_type") or ""),+ str(order.get("total_quantity") or order.get("quantity") or ""),str(order.get("limit_price") or ""),- str(order_status.get("status") or ""),+ _enum_text(status_text or ""),)console.print(table)return EXIT_SUCCESS