diff --git a/api/main.py b/api/main.py index 24e3a1e..a353749 100644 --- a/api/main.py +++ b/api/main.py @@ -86,12 +86,22 @@ def _command_bus_enabled() -> bool: def _broker_block() -> dict: """Broker truth for the LIVE badge, derived from the base URL the services already have (not the execution_mode literal, which lied). Alpaca's paper host - is ``paper-api.alpaca.markets``; anything else is live money.""" + is ``paper-api.alpaca.markets``; Tradier's sandbox host starts with + ``sandbox.``; anything else is live money.""" from urllib.parse import urlparse as _urlparse + if os.environ.get("BROKER", "alpaca").strip().lower() == "tradier": + url = os.environ.get("TRADIER_BASE_URL") or ( + "https://api.tradier.com/v1" + if os.environ.get("TRADIER_ENV", "sandbox").strip().lower() == "live" + else "https://sandbox.tradier.com/v1") + host = _urlparse(url).hostname or url + return {"name": "TRADIER", "base_url_host": host, + "is_paper": host.startswith("sandbox.")} url = os.environ.get("ALPACA_BASE_URL") or "https://paper-api.alpaca.markets" host = _urlparse(url).hostname or url - return {"base_url_host": host, "is_paper": host.startswith("paper-api")} + return {"name": "ALPACA", "base_url_host": host, + "is_paper": host.startswith("paper-api")} def _eastern_session_date(): diff --git a/api/static/dashboard.html b/api/static/dashboard.html index ffef6c4..fd32cb7 100644 --- a/api/static/dashboard.html +++ b/api/static/dashboard.html @@ -1422,7 +1422,8 @@ function render(d) { const broker = d.broker || {}; const isPaper = broker.is_paper !== false; // default to paper when unknown const badge = $("mode-badge"); - badge.textContent = isPaper ? "PAPER · ALPACA" : "LIVE · ALPACA"; + const brokerName = broker.name || "ALPACA"; + badge.textContent = (isPaper ? "PAPER · " : "LIVE · ") + brokerName; badge.className = "badge " + (isPaper ? "paper" : "live"); const acct0 = (d.accounts || [])[0] || {}; badge.title = (broker.base_url_host || "") + (acct0.account_id ? " · " + acct0.account_id : "");