Repository navigation
fix(bracket): poll fill status before abandoning an undefined-state entry - #179
Merged
TexasCoding merged 1 commit intoOct 29, 2026
Merged
Conversation
…ntry When the fill wait returns but the order-status endpoint still reports 0 filled, place_bracket_order rechecked once after 1s, then cancelled the entry and raised. The status can lag a real fill by a few seconds, so a filled entry was left without its stop and target legs. Poll up to 6 x 1s instead. A fill seen during the window sizes the protective legs to the filled quantity and the bracket attaches; an order still at 0 filled after the window is cancelled and raised, as before. Tests: two added (a fill on a later recheck attaches the bracket and is never cancelled; an order that never fills is cancelled and raises). Both fail on main without the change; tests/order_manager/test_bracket_orders.py 34 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JNt1FrUdgq9YmgPfBeiSwm
Owner
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.
Follow-up to #98, as discussed there.
Problem
In
place_bracket_order, when the fill wait returns but_check_order_fill_statusstill reports 0 filled (the "undefined state" branch), the code rechecks once after 1 s, then cancels the entry and raisesfailed to fill after recheck. The status endpoint can lag a real fill by a few seconds. When it does, the entry is filled but the stop and target legs are never placed, so the position has no protection.Change
Tests
Two added to
tests/order_manager/test_bracket_orders.py:test_bracket_undefined_state_lagging_fill_attaches_bracket: a fill that appears on the second poll attaches the bracket and the entry is never cancelled.test_bracket_undefined_state_genuinely_unfilled_still_raises: an order that stays at 0 filled is cancelled and raises.Both fail on
mainwithout the change. The bracket test file passes with it (34 passed).ruff checkandruff format --checkare clean on both files.We have run this logic in production on our 3.5.9 fork since July.
🤖 Generated with Claude Code