Skip to content

fix(orderbook): continue reduce-only close recovery when a cancelled order fills - #349

Merged
jackhai9 merged 1 commit into
mainfrom
fix/reduce-only-recovery-cancel-lost-to-fill
Nov 10, 2026
Merged

jackhai9 merged 1 commit into
mainfrom
fix/reduce-only-recovery-cancel-lost-to-fill

Conversation

@jackhai9

Copy link
Copy Markdown
Owner

Problem

Near the tail of a continuous close, reduce-only recovery (after 90802022) cancels selected close orders. If a selected order fully fills after selection, its cancellation is rejected and no matching success receipt exists, and the task stopped with 未收到匹配的成功撤单回执,已停止重新挂单. Live JCTUSDT: stopped at round 202/204 while its last four close orders filled in the same second; the position ended at zero.

Change (2.7.247)

  • During reduce-only recovery an unconfirmed cancellation waits up to 3 s for a trusted account-stream FILLED frame for the exact identity (symbol, orderId, clientOrderId) and whole preflight quantity.
  • FILLED is terminal, so the page keeps the latest 200 whole-order fill frames and each cancellation batch starts from them (covers a fill that arrives before the batch while the row is still rendered).
  • With that evidence the batch ends like the existing vanished-target path: nothing is counted as released; the runner rereads the authoritative position.
  • Partial fill, foreign identity, liquidation frame, or no frame: existing stop. Ordinary replacements still stop.
  • Unconfirmed cancellations log Cancellation not confirmed with the first observed reason and whether fill evidence arrived.

Validation

  • Regression e2e fails on the previous code with the exact live status text.
  • New e2e: fill during the in-flight cancellation and before the batch (continue); no fill / partial fill (stop); Stop during the fill wait; ordinary replacement with a fill frame (stop). New unit tests for fill evidence and failure reasons.
  • Mutation checks: dropping the prior-fill seed or the reduce-only gate fails the corresponding test.
  • npm test 2661 passed; npm run test:ui 670 passed; lint:tests, lint:ui-copy, check:binance-userscripts, check:binance-orderbook-trade, git diff --check pass.
  • Independent read-only review: ship with fixes; all findings addressed.
  • Not verified on a live page yet.

🤖 Generated with Claude Code

…order fills

A reduce-only rejection (90802022) near the tail of a continuous close makes
the recovery cancel selected close orders. When one of them fully fills after
it was selected, its cancellation is rejected and no matching success receipt
exists, so the task stopped with "未收到匹配的成功撤单回执". A live JCTUSDT
close stopped that way at round 202/204 while its last four close orders
filled in the same second and the position reached zero.

During reduce-only recovery an unconfirmed cancellation now waits up to 3 s
for a trusted account-stream FILLED frame for that exact identity and its
whole preflight quantity. FILLED is terminal, so the page keeps the latest 200
whole-order fill frames and each batch starts from them. With that evidence
the batch ends like a vanished target: nothing is counted as released and the
runner rereads the authoritative position. Partial fills, foreign identities
or no frame keep the existing stop; ordinary replacements still stop.

Every unconfirmed cancellation now logs its first observed reason (not
dispatched, HTTP status, response code, another order, no/unreadable response,
multiple requests, response or account-event timeout).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jackhai9
jackhai9 merged commit c4b4e6c into main Nov 10, 2026
2 checks passed
@jackhai9
jackhai9 deleted the fix/reduce-only-recovery-cancel-lost-to-fill branch November 10, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant