-
Notifications
You must be signed in to change notification settings - Fork 0
feat(emitter,worker,filltracker): reconcile HyperLiquid orders and skip no-ops #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
emitter/emitter.go
Outdated
| func ordersMatch(status *hyperliquid.WsOrder, desired hyperliquid.CreateOrderRequest) bool { | ||
| if status == nil { | ||
| return false | ||
| } | ||
|
|
||
| if !strings.EqualFold(status.Order.Coin, desired.Coin) { | ||
| return false | ||
| } | ||
|
|
||
| side := strings.ToUpper(status.Order.Side) | ||
| if desired.IsBuy { | ||
| if side != "B" { | ||
| return false | ||
| } | ||
| } else { | ||
| if side != "S" { | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| size, err := strconv.ParseFloat(status.Order.Sz, 64) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| if !floatEquals(size, desired.Size) { | ||
| return false | ||
| } | ||
|
|
||
| price, err := strconv.ParseFloat(status.Order.LimitPx, 64) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| if !floatEquals(price, desired.Price) { | ||
| return false | ||
| } | ||
|
|
||
| return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider reduce-only when detecting satisfied orders
The new ordersMatch helper only compares coin, side, size and price before returning ErrOrderAlreadySatisfied. If the desired update only toggles flags such as ReduceOnly, the emitter now treats the order as already satisfied and skips emitting a modify, while filltracker still expects the reduce-only change to be applied. That leaves a live order in the wrong mode and can allow a take-profit that should be reduce-only to remain non–reduce-only. The equality check should include reduce-only (and other behavioural fields) before short-circuiting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codex go ahead and implement the fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
- Loaded the most recent stored submission before comparing cached Hyperliquid status so that reconciliation can detect when an existing order already matches the desired payload, including reduce-only transitions. emitter/emitter.goL134-L165
- Added matching logic for reduce-only flags and order type details when determining whether a live order satisfies the desired state, preventing behavioural updates from being skipped. emitter/emitter.goL295-L374
Testing
- ✅
go test ./...
|
@codex final review |
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
feat(emitter,worker,filltracker): reconcile HyperLiquid orders and skip no-ops
Added
ErrOrderAlreadySatisfiedand taught both the order worker and fill tracker to treat it as a skipped submission.Reworked the HyperLiquid emitter to reconcile against cached/live status, issue modifies for live orders, and short-circuit
when an existing order already matches the desired payload (including reduce-only transitions).
ErrOrderAlreadySatisfiedcmd/recomma, treatErrOrderAlreadySatisfiedas skipModifysubmitModifywith shared rate-limit handling & persistenceImplementation notes:
isLiveStatus,ordersMatch,orderTypesMatch,floatEquals,submitModify.ErrOrderAlreadySatisfiedwhen matched.https://chatgpt.com/codex/tasks/task_e_6902ba833fd083268a0b9ec2e74e6868