Skip to content

Commit

Permalink
fix user canceled logic
Browse files Browse the repository at this point in the history
  • Loading branch information
aforaleka committed Jun 17, 2024
1 parent 738682e commit 2b2fae3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ internal class OrderProcessor(parser: ParserProtocol) : BaseProcessor(parser) {
// if order is short-term order and indexer returns best effort canceled and has no partial fill
// treat as a pending order until it's partially filled or finalized
val isBestEffortCanceled = modified["status"] == "BEST_EFFORT_CANCELED"
val isNotUserCanceled = modified["cancelReason"] != "USER_CANCELED"
if (orderFlags.equals(Numeric.double.ZERO) && isBestEffortCanceled && isNotUserCanceled) {
val cancelReason = parser.asString(modified["cancelReason"])
val isUserCanceled = cancelReason == "USER_CANCELED" || cancelReason == "ORDER_REMOVAL_REASON_USER_CANCELED"
if (orderFlags.equals(Numeric.double.ZERO) && isBestEffortCanceled && !isUserCanceled) {
modified.safeSet("status", "PENDING")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,7 @@ class V4SubaccountTests : V4BaseTests() {
"size":"545",
"price":"2.201",
"type":"LIMIT",
"status":"BEST_EFFORT_CANCELED",
"status":"PENDING",
"timeInForce":"IOC",
"postOnly":false,
"reduceOnly":false,
Expand All @@ -1998,7 +1998,7 @@ class V4SubaccountTests : V4BaseTests() {
"size":"3540",
"price":"0.5649",
"type":"LIMIT",
"status":"BEST_EFFORT_CANCELED",
"status":"PENDING",
"timeInForce":"IOC",
"postOnly":false,
"reduceOnly":false,
Expand Down

0 comments on commit 2b2fae3

Please sign in to comment.