Skip to content

fix(trading): harden exchange-native protection orders - #365

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

brokermr810 merged 38 commits into
mainfrom
test

Conversation

@brokermr810

Copy link
Copy Markdown
Collaborator

Summary

Promotes the tested backend fixes from test to main.

Related issue

Closes #361
Supersedes #363 by preserving its contributor commit and extending the same safeguards across the remaining supported venues.

Changes

  • Preserve the Bitget and Bybit native-protection tick normalization from fix(trading): snap Bitget and Bybit native protection prices to the tick #363.
  • Normalize OKX, Gate, and HTX limit, stop-loss, take-profit, and activation prices to each venue's published tick size.
  • Reject native-protection requests when exchange quantity normalization produces zero, instead of sending an invalid order.
  • Preserve decimal-safe serialization for very small asset prices and avoid scientific-notation regressions where string prices are required.
  • Include the tested crypto candle coverage boundary fix already staged on test.

Test plan

  • 121 focused backend regression tests pass.
  • 63 direct native-protection and venue precision tests pass.
  • Ruff lint checks pass for all changed files.
  • Modified Python modules compile successfully.

API documentation

  • No route or schema changes.

Screenshots

Not applicable; backend-only changes.

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 7 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]>
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@brokermr810
brokermr810 merged commit d6a102d 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.

Exchange-native stop loss is silently never placed when the trigger price is not on a tick boundary

3 participants