-
Notifications
You must be signed in to change notification settings - Fork 1k
Port limit order filling for OrderMatchingEngine in Rust #2212
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
Port limit order filling for OrderMatchingEngine in Rust #2212
Conversation
3152655
to
b01a469
Compare
b01a469
to
05b0ffb
Compare
self.core.bid = self.target_bid; | ||
self.core.ask = self.target_ask; | ||
self.core.last = self.target_last; | ||
if let Some(target_bid) = self.target_bid { |
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.
Cython version has self._has_targets
variable, and Rust doesn't. But best to use native Option and check if the value is defined to achieve the same effect
} else if order.time_in_force() == TimeInForce::Fok | ||
|| order.time_in_force() == TimeInForce::Ioc | ||
{ | ||
self.cancel_order(order, None); |
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.
The problem here is that after self.accept_order
is called, the corresponding AcceptOrder
event is not applied anywhere, and it should be in generate_order_accepted
function. Basically we are doing a lot of processing on order object and we expect the status was changed, we we never call order.apply
anywhere in OrderMatchingEngine
code
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.
self.accept_order(order)
will call the ExecutionEngine
immediately which will apply the event along with other logic.
@@ -1242,6 +1458,8 @@ impl OrderMatchingEngine { | |||
)); | |||
let msgbus = self.msgbus.as_ref().borrow(); | |||
msgbus.send(&msgbus.switchboard.exec_engine_process, &event as &dyn Any); | |||
|
|||
order.apply(event).expect("Failed to apply order event"); |
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.
Should this be added there? The reasoning is here https://github.com/nautechsystems/nautilus_trader/pull/2212/files#r1916905546
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.
The event will be applied to the order in the ExecutionEngine
following the completion of msgbus.send(&msgbus.switchboard.exec_engine_process, &event as &dyn Any)
.
} else if order.time_in_force() == TimeInForce::Fok | ||
|| order.time_in_force() == TimeInForce::Ioc | ||
{ | ||
self.cancel_order(order, None); |
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.
self.accept_order(order)
will call the ExecutionEngine
immediately which will apply the event along with other logic.
@@ -1242,6 +1458,8 @@ impl OrderMatchingEngine { | |||
)); | |||
let msgbus = self.msgbus.as_ref().borrow(); | |||
msgbus.send(&msgbus.switchboard.exec_engine_process, &event as &dyn Any); | |||
|
|||
order.apply(event).expect("Failed to apply order event"); |
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.
The event will be applied to the order in the ExecutionEngine
following the completion of msgbus.send(&msgbus.switchboard.exec_engine_process, &event as &dyn Any)
.
Pull Request
OrderMatchingEngine