From 8bb5301fbb2e3b032cc36925165312f2bc81b207 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Sat, 10 Oct 2020 11:58:06 -0400 Subject: [PATCH] Not sure how I messed this up. --- .../matcher/FifoSecurityMatcher.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/server/sparkd/cmds/spartan/md/mdp3/back_testing/matcher/FifoSecurityMatcher.cpp b/src/server/sparkd/cmds/spartan/md/mdp3/back_testing/matcher/FifoSecurityMatcher.cpp index 1093ad16c..261fdfea4 100644 --- a/src/server/sparkd/cmds/spartan/md/mdp3/back_testing/matcher/FifoSecurityMatcher.cpp +++ b/src/server/sparkd/cmds/spartan/md/mdp3/back_testing/matcher/FifoSecurityMatcher.cpp @@ -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( nullptr, nullptr); @@ -66,7 +68,7 @@ void FifoSecurityMatcher::_cleanup() { }); } void FifoSecurityMatcher::_on_new_order(const MDP3Order &ord, - std::vector* res) { + std::vector* 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,