added the 0 leg check
This commit is contained in:
1 parent
c3292d2f60
commit
809bd16e99
3 files changed
+20
-1
No files matched your search
@@ -387,7 +387,12 @@ void SpreaderOrder::_report_state (){
|
||||
if (_activated()){
|
||||
SpreaderBookkeepingData& bookkeeping_data = _bookkeeping_data();
|
||||
auto& reported_state = bookkeeping_data.reported_state();
|
||||
api::orderman::OrderStatus status = _get_order_status ();
|
||||
api::orderman::OrderStatus status =
|
||||
// this is a temporary solution, until we get sniper working.
|
||||
// if there are no quoting legs, we simply mark the order
|
||||
// as cancelled (instead of completed with 0 filled qty)
|
||||
bookkeeping_data.n_quoting_legs() == 0 ? bts::api::orderman::OrderStatus::ORDER_STATUS_CANCELED :
|
||||
_get_order_status ();
|
||||
if(bookkeeping_data.inited_new()){
|
||||
Quantity filled_qty; Price avg_filled_price;
|
||||
bookkeeping_data.total_fills(filled_qty, avg_filled_price);
|
||||
|
||||
@@ -12,6 +12,7 @@ SpreaderBookkeepingData::SpreaderBookkeepingData (ISpreaderManager& spreader_man
|
||||
:
|
||||
_is_live(spreader_pao_services.is_live()),
|
||||
_n_legs(legs.size()),
|
||||
_n_quoting_legs(_calc_n_quoting_legs(legs)),
|
||||
_inited_new (inited_new),
|
||||
_order_def(order_def),
|
||||
_reported_state(){
|
||||
@@ -62,6 +63,14 @@ SpreaderBookkeepingData(spreader_manager,
|
||||
false){
|
||||
_reported_state=order_record.state();
|
||||
}
|
||||
size_t SpreaderBookkeepingData::_calc_n_quoting_legs(
|
||||
const std::vector<LegPropertyData>& legs){
|
||||
size_t rv=0;
|
||||
for(const LegPropertyData& l : legs)
|
||||
if(l.is_active_quoting())
|
||||
rv++;
|
||||
return rv;
|
||||
}
|
||||
void SpreaderBookkeepingData::total_fills (Quantity& out_quantity,
|
||||
Price& out_price) const{
|
||||
double avg_price = 0.0;
|
||||
|
||||
@@ -22,6 +22,7 @@ class SpreaderBookkeepingData
|
||||
private:
|
||||
const bool _is_live;
|
||||
const size_t _n_legs;
|
||||
const size_t _n_quoting_legs;
|
||||
// when the order is not created from the disk
|
||||
// (ie created live) this is set to true
|
||||
const bool _inited_new;
|
||||
@@ -42,6 +43,7 @@ private:
|
||||
Price _input_price;
|
||||
Price _effective_price;
|
||||
Quantity _quantity;
|
||||
size_t _calc_n_quoting_legs(const std::vector<LegPropertyData>& legs);
|
||||
public:
|
||||
SpreaderBookkeepingData (ISpreaderManager& spreader_manager,
|
||||
bts::orderman::OrderKey spreader_order_key,
|
||||
@@ -134,5 +136,8 @@ public:
|
||||
bool has_effective_price() const{
|
||||
return !os::is_nan(_effective_price.value());
|
||||
}
|
||||
size_t n_quoting_legs() const{
|
||||
return _n_quoting_legs;
|
||||
}
|
||||
};
|
||||
}}
|
||||
Reference in new issue
Block a user