Skip to content

fix(grid): reconcile residual orders safely (builds on #407) - #408

Merged
brokermr810 merged 97 commits into
mainfrom
test
Nov 25, 2026
Merged

brokermr810 merged 97 commits into
mainfrom
test

Conversation

@brokermr810

Copy link
Copy Markdown
Collaborator

Summary

Builds on #407 by @Mystery01092000 to resolve stale grid order verification from #404, with bounded asynchronous recovery and stopped-strategy fill accounting.

Contributor credit

  • Original commit 46ef975f086c4215217a966598abf1a9f28a4084 is retained as cherry-pick e1fa7b7a7cb5fcab7bf16dfe675bca1801647507, preserving Pranav Tomar as its author.
  • The integration commit also contains Co-authored-by: Pranav Tomar <[email protected]>.
  • If squash-merging, retain that co-author trailer so the original contribution is credited.
  • fix(grid): resolve orders missing from open orders on verify #407 has not been remotely merged or closed; this PR is the combined replacement candidate.

Root cause

The open-orders snapshot cannot confirm a missing order's terminal state. The normal fill poller also skips strategies without a live local runner, leaving stopped grids with partial/full fills unreconciled. Synchronous UI verification would otherwise issue excessive exchange requests and miscount terminal orders as unverified.

Changes

  • Preserve fix(grid): resolve orders missing from open orders on verify #407's individual terminal-order lookup and atomic cancellation guard for confirmed zero-fill cancellations.
  • Queue verification through the existing durable trading-worker reconcile command; HTTP reads persisted per-order audit evidence instead of querying exchanges.
  • Bound missing-order lookups, cache recent results, and rotate older rows first.
  • Reconcile confirmed stopped-grid fills through the existing idempotent ledger projection, with account/binding, runtime epoch and lease checks. Accounting-only recovery never places follow-up orders or starts a runner.
  • Show verified terminal orders, queued verification, and pending ledger reconciliation distinctly.
  • Companion desktop frontend change: OpenByteInc/QuantDinger-Vue@3c52cb6, pushed to main with 11-language copy.

Verification

Tested exact committed snapshots, excluding unrelated local work:

  • Backend grid, execution, command and worker regressions: 405 passed.
  • PostgreSQL fill-accounting integration: 20 passed, including repeated partial-fill cancellation audits creating only one trade.
  • Eight additional submission integration cases were skipped because their dedicated disposable-database DSN was not configured; no live-exchange test was run.
  • Desktop frontend unit tests after integrating current main: 761 passed.
  • Frontend production build, locale completeness/encoding checks, backend quality checks and targeted Ruff checks passed.

Deployment and remaining boundaries

Co-authored-by: Pranav Tomar [email protected]

tianhe added 30 commits November 1, 2026 17:17
Signed-off-by: TIANHE <[email protected]>

# Conflicts:
#	backend_api_python/app/routes/community.py
tianhe and others added 20 commits November 21, 2026 14:18
…emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: TIANHE <[email protected]>

# Conflicts:
#	backend_api_python/app/services/strategy_v2/live_execution.py
#	backend_api_python/app/services/trading_executor.py
#	backend_api_python/tests/test_strategy_v2_order_gateway.py
#	docs/trading/LIVE_TRADING_SAFETY.md
#	docs/trading/LIVE_TRADING_SAFETY_CN.md
Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>
Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: TIANHE <[email protected]>

# Conflicts:
#	docs/trading/LIVE_TRADING_SAFETY.md
#	docs/trading/LIVE_TRADING_SAFETY_CN.md
Signed-off-by: TIANHE <[email protected]>

# Conflicts:
#	backend_api_python/tests/integration/test_runtime_readiness.py
The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>
Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@brokermr810
brokermr810 merged commit 4e5a8c6 into main Nov 25, 2026
16 checks passed
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.

4 participants