Not sure how I messed this up.

This commit is contained in:
Pedro Pinto committed 2020-10-10 11:58:06 -04:00
1 parent 3a73b6cb9e
commit 8bb5301fbb
1 file changed
+15 -3
@@ -39,8 +39,10 @@ FifoSecurityMatcher::_find_order(MDP3OrderKey key) {
auto map_it = _order_map.find(key);
if(map_it != _order_map.end()){
auto& ord = map_it->second;
FifoPriceLevelMatcher* p_level = _find_price_level(ord.side,ord.price);
return std::make_tuple(p_level,&ord);
if(ord.is_active){
FifoPriceLevelMatcher* p_level = _find_price_level(ord.side,ord.price);
return std::make_tuple(p_level,&ord);
}
}
return std::tuple<FifoPriceLevelMatcher *, MatcherOrder *>(
nullptr, nullptr);
@@ -66,7 +68,7 @@ void FifoSecurityMatcher::_cleanup() {
});
}
void FifoSecurityMatcher::_on_new_order(const MDP3Order &ord,
std::vector<MatchEffect>* res) {
std::vector<MatchEffect>* res) {
_log_trace_order(ord,"FifoSecurityMatcher::_on_new_order begin");
auto& opp_book = _book(_opp_side(ord.side));
uint32_t new_ord_rem = total_quantity(ord).value();
@@ -114,6 +116,16 @@ void FifoSecurityMatcher::_on_new_order(const MDP3Order &ord,
ord_corrected.quantity = MDP3Quantity(new_ord_rem);
price_level->on_new_same_side_order(ord_corrected);
}
else{
// since _on_new_order is also the same code path
// thats called when an order changes price levels
auto it = _order_map.find(ord.key);
if(it != _order_map.end()){
MatcherOrder& ex_ord = it->second;
ex_ord.quantity = MDP3Quantity(0);
ex_ord.is_active = false;
}
}
}
void FifoSecurityMatcher::_on_order_update(const MDP3Order &ord,