| | |
| | | |
| | | void Book::ask(Order& order) |
| | | { |
| | | auto a = |
| | | this->askSide.emplace(order.id, order); |
| | | auto a = this->askSide.emplace(order.id, order); |
| | | if (!a.second) { |
| | | std::cout << order.id << "already exists" << std::endl; |
| | | } |
| | |
| | | |
| | | void Book::bid(Order& order) |
| | | { |
| | | auto a = |
| | | this->bidSide.emplace(order.id, order); |
| | | auto a = this->bidSide.emplace(order.id, order); |
| | | if (!a.second) { |
| | | std::cout << order.id << "already exists" << std::endl; |
| | | } |
| | |
| | | { |
| | | std::cout << "Sell side: " << this->askSide.size() << std::endl; |
| | | std::vector<Level> askCopy; |
| | | for (auto i : this->askSide) askCopy.push_back(i.second); |
| | | for (auto i : this->askSide) |
| | | askCopy.push_back(i.second); |
| | | std::size_t count = 0; |
| | | std::sort(askCopy.begin(), askCopy.end()); |
| | | for (auto i = askCopy.rbegin(); i != askCopy.rend(); i++) { |
| | |
| | | } |
| | | std::cout << "Buy side: " << this->bidSide.size() << std::endl; |
| | | std::vector<Level> bidCopy; |
| | | for (auto i : this->bidSide) bidCopy.push_back(i.second); |
| | | for (auto i : this->bidSide) |
| | | bidCopy.push_back(i.second); |
| | | count = 0; |
| | | std::sort(bidCopy.begin(), bidCopy.end()); |
| | | for (auto i = bidCopy.rbegin(); i != bidCopy.rend(); i++) { |