simplified reporting
This commit is contained in:
1 parent
250fd8f570
commit
044d7725dc
5 files changed
+86
-79
No files matched your search
@@ -17,9 +17,7 @@ QueueHolderOrder::QueueHolderOrder()
|
||||
:
|
||||
_is_succ_inited(false),
|
||||
_is_recovered(false),
|
||||
_cancelled_externally(false),
|
||||
_unexpected_child_cancel(false),
|
||||
_child_error(false),
|
||||
_termination_reason(TerminationReason::NONE),
|
||||
_order_def(),
|
||||
_tick_size(bts::os::nan()),
|
||||
_order_builder(),
|
||||
@@ -72,22 +70,14 @@ void QueueHolderOrder::on_update(Price price,
|
||||
void QueueHolderOrder::on_crack(trace::CorID const &) {
|
||||
}
|
||||
void QueueHolderOrder::on_cancel(const trace::CorID&) {
|
||||
if(_state()!=QueueHolderOrderState::WAITING_FOR_CANCEL_ALL &&
|
||||
_state()!=QueueHolderOrderState::END){
|
||||
_cancelled_externally=true;
|
||||
_state_worker->on_cancel();
|
||||
_report_state();
|
||||
}
|
||||
_state_worker->on_cancel();
|
||||
_report_state();
|
||||
}
|
||||
void QueueHolderOrder::_on_book_update(const BookUpdateEvent& b) {
|
||||
_state_worker->on_book(b.book,b.trace);
|
||||
}
|
||||
void QueueHolderOrder::_on_child_order_update(
|
||||
const OrderStateUpdateEvent& c) {
|
||||
_unexpected_child_cancel = _unexpected_child_cancel ||
|
||||
_is_unexpected_child_cancel(c);
|
||||
_child_error = _child_error ||
|
||||
SpreaderUtils::order_in_error_state(c);
|
||||
const OrderStateUpdateEvent& c) {
|
||||
_state_worker->on_child_order_update(c);
|
||||
_report_state();
|
||||
}
|
||||
@@ -128,12 +118,44 @@ void QueueHolderOrder::_switch_state(QueueHolderOrderState new_state) {
|
||||
LOG(OrderMan, Info, "QueueHolderOrder::_switch_state key:{} {}->{}",
|
||||
key(), s0,_state_int());
|
||||
}
|
||||
bool QueueHolderOrder::_is_unexpected_child_cancel(
|
||||
const OrderStateUpdateEvent& c) const{
|
||||
bool expecting_cancel=
|
||||
_state()==QueueHolderOrderState::WAITING_FOR_CANCEL_ALL;
|
||||
return !expecting_cancel &&
|
||||
SpreaderUtils::order_in_cancelled_state(c.status);
|
||||
}
|
||||
api::orderman::OrderStatus QueueHolderOrder::status(std::string& message) const{
|
||||
QueueHolderOrderState curr_state=
|
||||
_state_worker==nullptr?QueueHolderOrderState::START:_state();
|
||||
switch (curr_state){
|
||||
case QueueHolderOrderState::START:
|
||||
case QueueHolderOrderState::WAITING_FOR_FIRST_ACK:
|
||||
case QueueHolderOrderState::WORKING:
|
||||
case QueueHolderOrderState::WAITING_FOR_CANCEL_ALL:
|
||||
return api::orderman::OrderStatus::ORDER_STATUS_WORKING;
|
||||
case QueueHolderOrderState::END:
|
||||
switch(_termination_reason){
|
||||
case TerminationReason::NONE:{
|
||||
// this will happen if the order is
|
||||
// recovered or the init failed
|
||||
bts_assert(!_is_succ_inited||_is_recovered);
|
||||
if(!_is_succ_inited){
|
||||
message="Could not initialize order";
|
||||
return api::orderman::OrderStatus::ORDER_STATUS_REJECTED_BY_SPARK;
|
||||
}
|
||||
else{
|
||||
message="Recovered order";
|
||||
// we could have done better here by [reserving ]
|
||||
return api::orderman::OrderStatus::ORDER_STATUS_COMPLETED;
|
||||
}
|
||||
}
|
||||
case TerminationReason::EXTERNAL_CANCEL:
|
||||
return api::orderman::OrderStatus::ORDER_STATUS_CANCELED;
|
||||
case TerminationReason::FILLED:
|
||||
return api::orderman::OrderStatus::ORDER_STATUS_COMPLETED;
|
||||
case TerminationReason::UNEXPECTED_CHILD_CANCEL:
|
||||
message="Child order cancelled";
|
||||
return api::orderman::OrderStatus::ORDER_STATUS_CANCELED;
|
||||
case TerminationReason::CHILD_ERROR:
|
||||
message="Child order error";
|
||||
return api::orderman::OrderStatus::ORDER_STATUS_CANCELED;
|
||||
}
|
||||
}
|
||||
return api::orderman::OrderStatus::ORDER_STATUS_WORKING;
|
||||
}
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
Reference in new issue
Block a user