Fixed limit enforcement bug in order activation.

This commit is contained in:
Pedro Pinto committed 2019-02-05 14:19:01 -05:00
1 parent b61cf170fe
commit d59d6fd095
2 files changed
+30 -29

No files matched your search

+29 -28
View File
@@ -275,7 +275,7 @@ void NativeOrder::on_init_from_exe_report(
NativeOrder::~NativeOrder() {}
void NativeOrder::_on_activate(Price p, Quantity q,
bool NativeOrder::_on_activate(Price p, Quantity q,
bts::orderman::OrderServices &services,
trace::CorID const &trace) {
auto scoped_log =
@@ -299,7 +299,7 @@ void NativeOrder::_on_activate(Price p, Quantity q,
"Dropping order {}",
key().value());
transition(ORDER_STATUS_REJECTED_BY_SPARK, "Exchange gateway is down");
return;
return false;
}
// can we trade?
@@ -315,7 +315,7 @@ void NativeOrder::_on_activate(Price p, Quantity q,
transition(ORDER_STATUS_REJECTED_BY_SPARK,
fmt::format("Unauthorized order: {}", lqr.error_msg));
return;
return false;
}
// can we trade this security, with this size?
@@ -332,7 +332,7 @@ void NativeOrder::_on_activate(Price p, Quantity q,
transition(ORDER_STATUS_REJECTED_BY_SPARK,
fmt::format("Order would breach limit: {}", lqr.error_msg));
return;
return false;
}
// are we under the messaging threshold?
@@ -343,7 +343,7 @@ void NativeOrder::_on_activate(Price p, Quantity q,
key().value());
transition(ORDER_STATUS_REJECTED_BY_SPARK,
"Messaging threshold breached");
return;
return false;
}
// if we are here we are good.
@@ -382,21 +382,22 @@ void NativeOrder::_on_activate(Price p, Quantity q,
auto const &ts = services.get_time_str();
me->create_transact_time_bm = encoding.overwrite(
me->create_transact_time_bm, &ts.value()[0], ts.value().size());
return true;
}
void NativeOrder::warm_up_activate(OrderServicesData&data, OrderServices& services) {
void NativeOrder::warm_up_activate(OrderServicesData &data,
OrderServices &services) {
bts_assert(!me->services);
me->services = &services;
init_order_services(data,services);
_on_activate(Price(0),Quantity(0),services, trace::CorID{});
init_order_services(data, services);
_on_activate(Price(0), Quantity(0), services, trace::CorID{});
me->services->unsubscribe_from_exe_report(
*me->session_services,me->exe_report_sid);
me->services->unsubscribe_from_cancel_reject(
*me->session_services,me->cancel_reject_sid);
me->services->unsubscribe_from_gateway_status(
*me->session_services);
me->services = nullptr;
me->services->unsubscribe_from_exe_report(*me->session_services,
me->exe_report_sid);
me->services->unsubscribe_from_cancel_reject(*me->session_services,
me->cancel_reject_sid);
me->services->unsubscribe_from_gateway_status(*me->session_services);
me->services = nullptr;
}
void NativeOrder::on_activate(Price p, Quantity q,
@@ -407,22 +408,22 @@ void NativeOrder::on_activate(Price p, Quantity q,
switch (me->state.status()) {
case ORDER_STATUS_INACTIVE: {
case ORDER_STATUS_INACTIVE:
// this is a brand new order
if (_on_activate(p, q, services, trace)) {
me->services->queue_fix(*me->session_services,
jetfix::MessageTypes::NewOrderSingle,
me->create_encoding, trace);
_on_activate(p,q,services,trace);
me->services->queue_fix(*me->session_services,
jetfix::MessageTypes::NewOrderSingle,
me->create_encoding, trace);
me->services->governor(*me->session_services).record_sent();
me->state.set_status(ORDER_STATUS_PENDING_WORKING);
me->services->governor(*me->session_services).record_sent();
me->state.set_status(ORDER_STATUS_PENDING_WORKING);
LOG(OrderMan, Info, "Sent new order with key {} to gateway",
key().value());
// early return so we skip the expensive report_state() call
return;
}
LOG(OrderMan, Info, "Sent new order with key {} to gateway",
key().value());
// early return so we skip the expensive report_state() call
return;
}
break;
// all cases below are for orders recovered from disk
case ORDER_STATUS_WORKING:
+1 -1
View File
@@ -39,7 +39,7 @@ protected:
struct PImpl;
std::unique_ptr<PImpl> me;
void _on_activate(Price, Quantity, bts::orderman::OrderServices &,
bool _on_activate(Price, Quantity, bts::orderman::OrderServices &,
trace::CorID const &);
void on_exe_report(const NewExecutionReportEvent &);
void on_cancel_reject(const CancelRejectEvent &);