This commit is contained in:
Pedro Pinto committed 2020-09-01 17:13:47 -04:00
commit 8cc564da96
3 files changed
+23 -12

No files matched your search

+1 -1
View File
@@ -74,7 +74,7 @@ std::map<std::string, std::function<int(std::vector<std::string> const &)>>
}
auto current_orders = s->orders();
add_iceberg_annotation(current_orders);
if (!matcher.has_same_orders(current_orders)) {
if (matcher.has_same_orders(current_orders).has_value()) {
std::cout << "Failing on event:\n " << ev.event_id
<< std::endl;
std::cout << "Old Orders:\n " << std::endl
@@ -239,10 +239,9 @@ void FifoSecurityMatcher::on_order_remove(MDP3OrderKey key){
_remove_empty_price_levels();
}
bool FifoSecurityMatcher::has_same_orders(const Orders& ord_map){
auto i=0;
std::optional<std::string> FifoSecurityMatcher::has_same_orders(
const Orders& ord_map){
for (const auto& kv : ord_map){
i++;
const auto& exp_ord = kv.second;
auto[plevel,ord] = _find_order(exp_ord.key);
auto match = plevel != nullptr && ord != nullptr &&
@@ -250,15 +249,27 @@ bool FifoSecurityMatcher::has_same_orders(const Orders& ord_map){
plevel->side()==exp_ord.side &&
ord->quantity == exp_ord.quantity;
if(!match){
auto pl = _find_price_level(exp_ord.side,exp_ord.price);
(void) pl;
// debug_break();
// bts_assert(false);
// bts_assert(pl != nullptr);
return false;
std::ostringstream buff;
if(ord == nullptr)
buff<<"Order with Key:"<<exp_ord.key.value()<<" not found";
else{
buff<<"Order with Key:"<<exp_ord.key.value()<<" does not match"<<std::endl;
buff<<"Expected price:"<<exp_ord.price<<" matcher:"<<plevel->price()<<std::endl;
buff<<"Expected qty:"<<exp_ord.quantity<<" matcher:"<<ord->quantity<<std::endl;
buff<<"Expected side:"<<exp_ord.side<<" matcher:"<<plevel->side()<<std::endl;
uint32_t exp_ib_val = exp_ord.iceberg_quantity.has_value()?
exp_ord.iceberg_quantity.value().value():0,
matcher_ib_val = ord->ib.is_ib?
ord->ib.total_qty.value():0;
buff<<"Expected IB state:"<<exp_ib_val<<" matcher:"<<matcher_ib_val<<std::endl;
}
LOG(OrderMan, Error, "FifoSecurityMatcher::has_same_orders failed:{}",
buff.str());
return std::optional<std::string>{buff.str()};
}
}
return true;
LOG(OrderMan, Info, "FifoSecurityMatcher::has_same_orders passed");
return std::nullopt;
}
}
@@ -56,6 +56,6 @@ public:
void on_order_update(const MDP3Order&);
void on_order_remove(MDP3OrderKey);
// For testing
bool has_same_orders(Orders const&);
std::optional<std::string> has_same_orders(Orders const&);
};
} // namespace bts::spartan::mdp3