| | |
| | | json::DeletedMessage* message) |
| | | { |
| | | if (message->side == book::Buy) { |
| | | bs[message->product].bidSide.erase(message->id); |
| | | for (auto i = bs[message->product].bidSide.begin(); i != bs[message->product].bidSide.end(); i++) { |
| | | if (i->id == message->id) { |
| | | bs[message->product].bidSide.erase(i); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | bs[message->product].askSide.erase(message->id); |
| | | for (auto i = bs[message->product].askSide.begin(); i != bs[message->product].askSide.end(); i++) { |
| | | if (i->id == message->id) { |
| | | bs[message->product].askSide.erase(i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | void tradeOrder(std::unordered_map<std::string, book::Book>& bs, |
| | | json::TradeMessage* message) |
| | | { |
| | | if (bs.find(message->passiveOrder) != bs.end()) { |
| | | if (message->tradeType == json::BUY_AGGRESSOR) { |
| | | if (message->passiveOrderRemaining > 0) { |
| | | bs[message->product].askSide.at(message->passiveOrder).volume = |
| | | message->passiveOrderRemaining; |
| | | for (auto& i : bs[message->product].askSide) { |
| | | if (i.id == message->passiveOrder) { |
| | | i.volume = message->passiveOrderRemaining; |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | bs[message->product].askSide.erase(message->passiveOrder); |
| | | for (auto i = bs[message->product].askSide.begin(); i != bs[message->product].askSide.end(); i++) { |
| | | if (i->id == message->passiveOrder) { |
| | | bs[message->product].askSide.erase(i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else if (message->tradeType == json::SELL_AGGRESSOR) { |
| | | if (message->passiveOrderRemaining > 0) { |
| | | bs[message->product].bidSide.at(message->passiveOrder).volume = |
| | | message->passiveOrderRemaining; |
| | | for (auto& i : bs[message->product].bidSide) { |
| | | if (i.id == message->passiveOrder) { |
| | | i.volume = message->passiveOrderRemaining; |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | bs[message->product].bidSide.erase(message->passiveOrder); |
| | | for (auto i = bs[message->product].bidSide.begin(); i != bs[message->product].bidSide.end(); i++) { |
| | | if (i->id == message->passiveOrder) { |
| | | bs[message->product].bidSide.erase(i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |