When adding a bid when taking their is an higher ask, it never sell.
Reason:
Because we use a template function (add<T>) to manage the OrderBook bid and ask, the condition when exiting the while is wrong when the order type is Ask:
for (auto &[_key, _val] : _book) {
if (_key > _price) // this condition is wrong
break;
OrderList &ol = _book.at(_key);
Problem:
When adding a bid when taking their is an higher ask, it never sell.
Reason:
Because we use a template function (
add<T>
) to manage theOrderBook
bid and ask, the condition when exiting the while is wrong when the order type isAsk
:The actual reason of this behavior is because we use 2 differents sorting algorithm for
BidBook
andAskBook
: