Repository navigation
Conversation
OpenByteInc#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 OpenByteInc#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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
5 tasks done
Collaborator
|
Thank you for the fix and the thorough tests. We preserved your commit and authorship in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
#362 fixed the Binance side of #361, but Bitget (UTA and classic) and Bybit still send native protection prices with plain
str(). A 2.5% stop on a 76049.9 short goes out as77951.14749999999, which isn't on the contract tick, the same precision problem Binance rejected in #361. This applies the same treatment #362 gave Binance to the other two venues.Related issue
Changes
stopLoss,takeProfitand the trailingactivationPricego throughclient._normalize_price+client._dec_str, same pattern as fix(trading): normalize Binance native protection orders #362.loss_plan/profit_planandmoving_plantriggerPricedo too, sopriceEndStepis respected (e.g. step 0.5).triggerPrice, the trailingactivePrice, and thetrailingStopdistance (entry * pct, also a price) are snapped totickSize.<venue>_native_protection_price_below_minimumif a price snaps to 0, like the Binance path. As with fix(trading): normalize Binance native protection orders #362, a leg that fails this raises after earlier legs are placed; the worker logs it and runtime protection stays on.str(price); their clients have no price-normalize helper, so I left them out.API documentation
Screenshots
Not applicable (backend-only fix).
Test plan
docker compose up -d --buildpython -m pytest tests/test_native_protection.py -qpasses (16). The three new tests use the issue's numbers and fail onmain. The existing Bitget UTA assertion changed from"90.0"to"90"since prices now go through_dec_str, and the existing classic test stubsget_contractso it doesn't hit the network.ruff checkandscripts/backend_quality_check.pypass. I also ranPendingOrderWorker._attach_native_protectionagainst Bybit and Bitget clients with a faked HTTP layer that rejects off-tick prices: all three were rejected onmain, and after the change they place77951.1(Bybit, UTA) and77951(classic, 0.5 step).