Added a few comments.

This commit is contained in:
Pedro Pinto committed 2019-02-12 09:50:32 -05:00
1 parent a9fc3d43a0
commit 904023c5fa
1 file changed
+37 -32
+37 -32
View File
@@ -180,7 +180,7 @@ void NativeOrder::on_init_recovered(OrderRecord const &rec,
}
}
api::orderman::OrderDefinition
api::orderman::OrderDefinition
NativeOrder::on_init_from_exe_report(ExecutionReport const &er,
const PreActivationOrderServices &os) {
auto k = er.order_key;
@@ -276,22 +276,21 @@ NativeOrder::on_init_from_exe_report(ExecutionReport const &er,
NativeOrder::~NativeOrder() {}
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);
init_order_services(data, services);
_on_activate(Price(0), Quantity(0), services);
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;
}
bool NativeOrder::_on_activate(Price p, Quantity q,
bts::orderman::OrderServices &services) {
me->state.set_price(p.value());
@@ -406,23 +405,29 @@ OrderOpResult NativeOrder::on_activate(Price p, Quantity q,
switch (me->state.status()) {
case ORDER_STATUS_INACTIVE: {
auto scoped_log =
services.log_scope("NativeOrder::on_activate", key().value());
// this is a brand new order
if (_on_activate(p,q,services)) {
me->services->queue_fix(*me->session_services,
jetfix::MessageTypes::NewOrderSingle,
me->create_encoding);
me->services->governor(*me->session_services).record_sent();
me->state.set_status(ORDER_STATUS_PENDING_WORKING);
if (_on_activate(p, q, services)) {
auto scoped_log =
services.log_scope("NativeOrder::on_activate", key().value());
me->services->queue_fix(*me->session_services,
jetfix::MessageTypes::NewOrderSingle,
me->create_encoding);
LOG(OrderMan, Info, "Sent new order with key {} to gateway",
key().value());
// early return so we skip the expensive report_state() call
return OrderOpResult{};
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. It is OK to spkip it because we are bound to report
// our state once the excange aknowledges the order.
return OrderOpResult{};
}
// When the order fails its limits checks we fall through the
// switch to report the error state at the end of this function
break;
}
@@ -589,9 +594,7 @@ OrderOpResult NativeOrder::on_update(Price p, Quantity q) {
return OrderOpResult{};
}
OrderOpResult NativeOrder::on_detach() {
return OrderOpResult{};
}
OrderOpResult NativeOrder::on_detach() { return OrderOpResult{}; }
OrderOpResult NativeOrder::on_cancel() {
auto scoped_log =
@@ -605,7 +608,8 @@ OrderOpResult NativeOrder::on_cancel() {
me->cancel_transact_time_bm, &ts.value()[0], ts.value().size());
me->services->queue_fix(*me->session_services,
jetfix::MessageTypes::Cancel, me->cancel_encoding);
jetfix::MessageTypes::Cancel,
me->cancel_encoding);
break;
}
@@ -652,8 +656,8 @@ bool NativeOrder::is_old_exe_report(
}
void NativeOrder::on_exe_report(const NewExecutionReportEvent &er) {
auto scoped_log = me->services->log_scope(
"NativeOrder::on_exe_report", key().value());
auto scoped_log =
me->services->log_scope("NativeOrder::on_exe_report", key().value());
auto &state = me->state;
auto &native_state = get_native_state(state);
@@ -707,7 +711,8 @@ void NativeOrder::on_exe_report(const NewExecutionReportEvent &er) {
native_state.set_native_type(er.data->order_type);
bool got_first_exchange_order_id = !me->received_exchanged_order_id;
if (got_first_exchange_order_id) {
native_state.set_exchange_order_id(to_trim_str(er.data->exchange_order_id));
native_state.set_exchange_order_id(
to_trim_str(er.data->exchange_order_id));
add_exchange_order_id_to_fix();
}