Joel Grunbaum
2022-01-10 2c515f0de70ad675b5f5d25b6a496d67d8dc0463
book.cpp
@@ -80,10 +80,9 @@
{
}
Book::Book(ProductTypeEnum productType, std::string product,
           int stationId, std::string unit,
           std::chrono::nanoseconds expiry, double aggFee, double pasFee,
           double broFee)
Book::Book(ProductTypeEnum productType, std::string product, int stationId,
           std::string unit, std::chrono::nanoseconds expiry, double aggFee,
           double pasFee, double broFee)
    : bidSide{}, askSide{}, productType{productType}, product(product),
      stationId(stationId), unit(unit), expiry(expiry), aggFee(aggFee),
      pasFee(pasFee), broFee(broFee)
@@ -108,7 +107,7 @@
   }
    }
    if (order.remaining_volume > 0) {
   this->askSide.emplace(this->askSide.begin(), order);
      this->askSide.emplace_back(order);
   std::make_heap(this->askSide.begin(), this->askSide.end(),
                  std::greater<Level>());
    }
@@ -132,7 +131,7 @@
   }
    }
    if (order.remaining_volume > 0) {
   this->bidSide.emplace(this->bidSide.begin(), order);
      this->bidSide.emplace_back(order);
   std::make_heap(this->bidSide.begin(), this->bidSide.end(),
                  std::less<Level>());
    }
@@ -144,15 +143,24 @@
    std::vector<Level> askCopy(this->askSide);
    std::size_t count = 0;
    std::sort(askCopy.begin(), askCopy.end());
    for (auto i = askCopy.rbegin(); i != askCopy.rend() && count < numOrders; i++, count++) {
        std::cout << *i << std::endl;
   std::reverse(askCopy.begin(), askCopy.end());
   uint64_t volume = 0;
   double price = askCopy.front().price;
   for (auto i : askCopy) {
      std::cout << i << std::endl;
      count++;
      if (count > numOrders) break;
    }
    std::cout << "Buy side: " << this->bidSide.size() << std::endl;
    std::vector<Level> bidCopy(this->bidSide);
    count = 0;
    std::sort(bidCopy.begin(), bidCopy.end());
    for (auto i = bidCopy.rbegin(); i != bidCopy.rend() && count < numOrders; i++, count++) {
        std::cout << *i << std::endl;
   std::reverse(bidCopy.begin(), bidCopy.end());
   price = bidCopy.front().price;
   for (auto i : bidCopy) {
      std::cout << i << std::endl;
      count++;
      if (count > numOrders) break;
    }
    }