fix: label broker sync events by actual execution broker (tradier stack)
Tradier stack emitted account/positions/orders events hardcoded as broker_name=alpaca_paper while the executor filters snapshots by client.broker_name (tradier) — position cap and re-entry block read zero positions, and the dashboard showed 'Alpaca Paper' over real Tradier values. Mode label now defaults from BROKER/TRADIER_ENV (tradier_live) instead of alpaca_paper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
485cec0372
commit
3871bda616
4 files changed
+41
-14
No files matched your search
+11
-4
@@ -5,7 +5,7 @@ from dataclasses import dataclass
|
||||
from typing import Literal, cast
|
||||
|
||||
|
||||
TradingMode = Literal["schwab_live", "alpaca_paper"]
|
||||
TradingMode = Literal["schwab_live", "alpaca_paper", "tradier_live", "tradier_sandbox"]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -17,7 +17,14 @@ class TradingModeSettings:
|
||||
values = dict(os.environ)
|
||||
if env is not None:
|
||||
values.update(env)
|
||||
mode = values.get("TRADING_EXECUTION_MODE", "alpaca_paper")
|
||||
if mode not in {"schwab_live", "alpaca_paper"}:
|
||||
mode = "alpaca_paper"
|
||||
# BROKER=tradier swaps the execution client, so the default mode label
|
||||
# must follow it — else the Tradier stack reports "alpaca_paper".
|
||||
if values.get("BROKER", "alpaca").strip().lower() == "tradier":
|
||||
sandbox = values.get("TRADIER_ENV", "sandbox").strip().lower() != "live"
|
||||
default = "tradier_sandbox" if sandbox else "tradier_live"
|
||||
else:
|
||||
default = "alpaca_paper"
|
||||
mode = values.get("TRADING_EXECUTION_MODE", default)
|
||||
if mode not in {"schwab_live", "alpaca_paper", "tradier_live", "tradier_sandbox"}:
|
||||
mode = default
|
||||
return cls(execution_mode=cast(TradingMode, mode))
|
||||
Reference in new issue
Block a user