Skip to content

Commit

Permalink
fix to return if a limit order is entirely filled
Browse files Browse the repository at this point in the history
  • Loading branch information
Kautenja committed Feb 16, 2020
1 parent cc0fbc2 commit 5e573f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/limit_order_book.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ class LimitOrderBook {
if (buys.best != nullptr && price <= buys.best->key) { // crosses
// place a market order with the limit price
buys.market(&orders.at(order_id), [&](UID uid) { orders.erase(uid); });
if (orders.at(order_id).size == 0) // order filled
if (orders.at(order_id).size == 0) { // order filled
orders.erase(order_id);
return;
}
}
sells.limit(&orders.at(order_id));
}
Expand All @@ -68,8 +70,10 @@ class LimitOrderBook {
if (sells.best != nullptr && price >= sells.best->key) { // crosses
// place a market order with the limit price
sells.market(&orders.at(order_id), [&](UID uid) { orders.erase(uid); });
if (orders.at(order_id).size == 0) // order filled
if (orders.at(order_id).size == 0) { // order filled
orders.erase(order_id);
return;
}
}
buys.limit(&orders.at(order_id));
}
Expand Down

0 comments on commit 5e573f9

Please sign in to comment.