Skip to content

fix(trading): enforce liquidation-aware strategy risk stops - #366

Merged
brokermr810 merged 40 commits into
mainfrom
test
Nov 11, 2026
Merged

brokermr810 merged 40 commits into
mainfrom
test

Conversation

@brokermr810

Copy link
Copy Markdown
Collaborator

Summary

  • Scope live equity-risk accounting and position ownership to the current strategy run.
  • Stop strategies after confirmed exchange liquidation or ADL across Binance, Bybit, OKX, Bitget, Gate, and HTX.
  • Handle already-flat exchange positions without reopening grid entries, and persist the actual stop reason.
  • Repair signal virtual-account capital consistency and harden legacy grid-ledger reconciliation.
  • Add idempotent database migrations for run identity and capital-basis repair.

Validation

  • 296 backend tests passed.
  • Python compileall passed.
  • Exchange forced-close, grid recovery, virtual account, lifecycle, and equity-stop regressions covered.

Fixes #364

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 10 commits November 6, 2026 15:07
#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@brokermr810
brokermr810 merged commit d1cf268 into main Nov 11, 2026
15 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.

[Bug] OKX模拟盘API被误识别为实盘,导致策略启动瞬间出现-707%巨额亏损

3 participants