-
Notifications
You must be signed in to change notification settings - Fork 777
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
Fixing USER_SUSPEND method #102
base: master
Are you sure you want to change the base?
Conversation
@@ -61,6 +61,9 @@ | |||
USER_MGMT_USER_NOT_SUSPENDABLE_NON_EMPTY_ACCOUNTS(-4131), | |||
USER_MGMT_USER_NOT_SUSPENDED(-4132), | |||
USER_MGMT_USER_ALREADY_SUSPENDED(-4133), | |||
USER_MGMT_USER_NOT_REMOVABLE_HAS_POSITIONS(-4134), | |||
USER_MGMT_USER_NOT_REMOVABLE_NON_EMPTY_ACCOUNTS(-4135), | |||
USER_SUSPENDED(-4136), |
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.
You can rename to RISK_USER_SUSPENDED(-2005), because this is directly related to the Risk Control section.
This is was a bug indeed, suspended users can not place any new order. Thanks for fixing it.
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.
Done. You are most welcome, thanks to you for sharing this awesome work !
@@ -203,6 +211,10 @@ static CommandResultCode processCommand(final IOrderBook orderBook, final OrderC | |||
cmd.marketData = orderBook.getL2MarketDataSnapshot(size >= 0 ? size : Integer.MAX_VALUE); | |||
return CommandResultCode.SUCCESS; | |||
|
|||
} else if (commandType == OrderCommandType.SUSPEND_USER) { | |||
|
|||
return orderBook.cancelOrdersByUid(cmd); |
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.
Suspending users should not cancel existing orders as this is expensive (not low-latency) operation. Approach is different. I will put a description into the PR.
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.
Check this idea please:
#102 (comment)
Initial idea of users removal was:
Straight forward removal with just a single command of caurse looks much easier for beginners. It has potential latency penalty. But i think we can add it if can proce consistency gurantees for such commands. |
src/main/java/exchange/core2/core/orderbook/OrderBookNaiveImpl.java
Outdated
Show resolved
Hide resolved
@@ -30,6 +30,9 @@ | |||
// After cancel/reduce order - risk engine should unlock deposit accordingly | |||
REDUCE, | |||
|
|||
// cancel orders of suspended users | |||
SUSPEND, |
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.
I think you shoud issue N * REDUCE events (for each cancelled order).
Because introducing new event type can make events handling much more difficult.
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.
Done.
Thank you for your review of the code and all infos you've shared and the way it can be improved. What if we can allow the admin to choose between issuing a SUSPEND user request to: The command will be sent as orderId (0 or 1), 1 to allow removing orders. |
Not yet finished
WORK IN PROGRESS
I have to figure out the way accounts balance are updated when an order is cancelled.