Harden order/risk path (execution+broker audit): 3 HIGH + 2 MED + 1 LOW
HIGH: - Circuit breaker fails CLOSED: a repeated unreadable equity (API 401/429/5xx or missing field) now halts new entries after 3 consecutive failures instead of silently reporting 'no breach' and continuing to trade through a drawdown. - execute(): map order statuses. Terminal-fail (rejected/expired/...) -> ok=False (never armed as a resting entry); record ANY fill (partial too), not only an exact 'filled'; require a real broker order id. approve_order only arms genuinely OPEN statuses. - sync: account/positions/orders failures now emit a BrokerHealthChangedEvent (degraded) and step_sync surfaces 'DEGRADED', instead of a success-shaped None that left risk gates reading stale snapshots as current. MEDIUM: - _flatten_all records a position closed only on a CONFIRMED close; the breaker event reports 'halted_flatten_incomplete' + the unclosed symbols when a close fails, instead of claiming the book is flat. - submit_exit_order prefers close_position (handles short sign + fractional qty; a plain sell of abs(qty) would double a short). LOW: - get_orders(nested=true) so bracket child legs aren't dropped from the snapshot. + tests/unit/test_execution_safety.py (4 regressions). 75/75 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
c146341bb4
commit
660cd494d5
6 files changed
+200
-21
No files matched your search
+3
-2
@@ -335,8 +335,9 @@ def main(argv: list[str] | None = None) -> int:
|
||||
def step_sync():
|
||||
if not rt["sync"]:
|
||||
return "skipped (no keys)"
|
||||
rt["sync"].sync_all()
|
||||
return "ok"
|
||||
res = rt["sync"].sync_all()
|
||||
failed = [k for k, v in res.items() if v is None]
|
||||
return "ok" if not failed else f"DEGRADED ({', '.join(failed)})"
|
||||
|
||||
def step_execute():
|
||||
if not rt["execution"]:
|
||||
|
||||
Reference in new issue
Block a user