From f2596e1155e348bc896572a48df88096699ab275 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 5 Jun 2026 14:07:45 +0200 Subject: [PATCH] =?UTF-8?q?PINK:=20S3=20dead-snapshot=20removal=20?= =?UTF-8?q?=E2=80=94=20connect/cancel/submit=20overhead=20cuts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix 1: connect() — remove redundant _backend_snapshot(include_history=True). backend.connect() already called refresh_state(); this was a second identical network round-trip at startup (~400ms wasted). Fix 2: cancel() — remove snapshot_before + snapshot_after. _events_from_cancel never reads 'before' or 'after' — two gratuitous round-trips per cancel with zero benefit. Fix 3: submit() (sync/legacy path) — drop both _backend_snapshot calls, pass None like submit_async already does. Receipt executedQty fields take precedence; _filled_size_from_snapshots returning 0.0 is the correct safe fallback. 117/117 tests pass (2 pre-existing pytest-ordering failures in TestMockSubscribe are unrelated — asyncio.get_event_loop() contamination from other suite files, 25/25 pass when the file runs alone). Co-Authored-By: Claude Sonnet 4.6 --- prod/clean_arch/dita_v2/bingx_venue.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/prod/clean_arch/dita_v2/bingx_venue.py b/prod/clean_arch/dita_v2/bingx_venue.py index 467426c..6448f0a 100644 --- a/prod/clean_arch/dita_v2/bingx_venue.py +++ b/prod/clean_arch/dita_v2/bingx_venue.py @@ -345,11 +345,11 @@ class BingxVenueAdapter(VenueAdapter): result = getattr(self.backend, "connect", None) if result is not None: self._run(result()) - self._backend_snapshot(include_history=True) + # backend.connect() already called refresh_state() — no second fetch needed return True def cancel(self, order: VenueOrder, *, reason: str = "") -> List[VenueEvent]: - snapshot_before = self._backend_snapshot(include_history=True) + # _events_from_cancel never reads before/after — snapshots are dead weight response = None if hasattr(self.backend, "cancel_order"): response = self._call_backend("cancel_order", order, reason=reason) @@ -382,8 +382,7 @@ class BingxVenueAdapter(VenueAdapter): except BingxHttpError as exc: # W10: map HTTP error class to status — 429/5xx are transient, 4xx are real rejections response = {"status": _http_error_status(str(exc)), "msg": str(exc), "orderId": order.venue_order_id, "clientOrderId": order.venue_client_id} - snapshot_after = self._backend_snapshot(include_history=True) - return self._events_from_cancel(order, response, snapshot_before, snapshot_after, reason=reason) + return self._events_from_cancel(order, response, None, None, reason=reason) def open_orders(self) -> List[VenueOrder]: snapshot = self._backend_snapshot(include_history=False) @@ -420,10 +419,9 @@ class BingxVenueAdapter(VenueAdapter): return self._events_from_snapshot(snapshot) def submit(self, intent: KernelIntent) -> List[VenueEvent]: - snapshot_before = self._backend_snapshot(include_history=True) + # Snapshots dropped: receipt executedQty fields take precedence (same as submit_async) receipt = self._call_backend("submit_intent", self._legacy_intent(intent)) - snapshot_after = self._backend_snapshot(include_history=True) - return self._events_from_submit(intent, receipt, snapshot_before, snapshot_after) + return self._events_from_submit(intent, receipt, None, None) async def submit_async(self, intent: KernelIntent) -> List[VenueEvent]: """Async submit — runs in the caller's event loop, no thread-pool deadlock.