Fixed algo API bug that could lead to lost order updates.
This commit is contained in:
1 parent
2a90b521da
commit
32038f8948
1 file changed
+14
-11
@@ -458,10 +458,21 @@ void AlgoWrapperOrder::detach_child(OrderKey child) {
|
||||
key().value(), child.value()));
|
||||
}
|
||||
|
||||
void AlgoWrapperOrder::detach_all_children() {
|
||||
if (!is_working())
|
||||
return;
|
||||
for (auto &[_, c] : me->children) {
|
||||
(void)_;
|
||||
c.order.mark_detached_from_parent();
|
||||
}
|
||||
me->children.clear();
|
||||
}
|
||||
|
||||
void AlgoWrapperOrder::update_fill_state(Quantity q, Price p) {
|
||||
if (!is_working())
|
||||
return;
|
||||
|
||||
ReportStateGuard _(*this);
|
||||
auto previous_qty = me->state().filled_quantity();
|
||||
if (previous_qty > q.value()) {
|
||||
LOG(OrderMan, Error,
|
||||
@@ -483,13 +494,14 @@ void AlgoWrapperOrder::update_fill_state(Quantity q, Price p) {
|
||||
void AlgoWrapperOrder::cancel(std::string const &msg) {
|
||||
if (!is_working())
|
||||
return;
|
||||
ReportStateGuard _(*this);
|
||||
terminate(ORDER_STATUS_CANCELED, msg);
|
||||
}
|
||||
|
||||
void AlgoWrapperOrder::terminate_error(std::string const &msg) {
|
||||
if (!is_working() && me->status != Status::W_ATTACH)
|
||||
return;
|
||||
|
||||
ReportStateGuard _(*this);
|
||||
// If we attached and an error was signaled we do not want to
|
||||
// cancel our child because that child might be a long running
|
||||
// order with a good queue position that we want to preserve
|
||||
@@ -498,19 +510,10 @@ void AlgoWrapperOrder::terminate_error(std::string const &msg) {
|
||||
terminate(ORDER_STATUS_ERROR, msg);
|
||||
}
|
||||
|
||||
void AlgoWrapperOrder::detach_all_children() {
|
||||
if (!is_working())
|
||||
return;
|
||||
for (auto &[_, c] : me->children) {
|
||||
(void)_;
|
||||
c.order.mark_detached_from_parent();
|
||||
}
|
||||
me->children.clear();
|
||||
}
|
||||
|
||||
void AlgoWrapperOrder::complete() {
|
||||
if (!is_working())
|
||||
return;
|
||||
ReportStateGuard _(*this);
|
||||
terminate(ORDER_STATUS_COMPLETED);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user