From 611ad7b12fcc6b34229316099ae66bccbcf24ad9 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Wed, 12 Jan 2022 06:12:35 +0000
Subject: [PATCH] Pull data from ftp and parse

---
 book.hpp |   90 +++++++++++++++++++++------------------------
 1 files changed, 42 insertions(+), 48 deletions(-)

diff --git a/book.hpp b/book.hpp
index 9e3a89c..27b6597 100644
--- a/book.hpp
+++ b/book.hpp
@@ -1,74 +1,68 @@
 #pragma once
 
+#include <algorithm>
 #include <chrono>
 #include <cstddef>
 #include <iostream>
 #include <queue>
 #include <string>
+#include <unordered_map>
 #include <vector>
-#include <algorithm>
 
+namespace book
+{
 enum OrderSideEnum { Buy, Sell };
 enum ProductTypeEnum { TEST, FUTURE, SPREAD, CALL, PUT };
 
 struct Order {
-  double price;
-  OrderSideEnum side;
-  int remaining_volume;
-  int filled_volume;
-  std::chrono::nanoseconds timestamp;
-  std::string id;
-  Order(double price, OrderSideEnum side, int volume,
-        std::chrono::nanoseconds timestamp, std::string id);
+	double price;
+	OrderSideEnum side;
+	int remaining_volume;
+	int filled_volume;
+	double timestamp;
+	std::string id;
+	Order(double price, OrderSideEnum side, int volume, double timestamp,
+	      std::string id);
 };
 
 struct Level {
-  double price;
-  int volume;
-  OrderSideEnum side;
-  std::chrono::nanoseconds timestamp;
-  std::string id;
+	double price;
+	int volume;
+	OrderSideEnum side;
+	double timestamp;
+	std::string id;
 
-  Level(Order &order);
+	Level(Order& order);
 };
 
-bool operator>(const Level &a, const Level &b);
-bool operator<(const Level &a, const Level &b);
-bool operator>=(const Level &a, const Level &b);
-bool operator<=(const Level &a, const Level &b);
-bool operator==(const Level &a, const Level &b);
+bool operator>(const Level& a, const Level& b);
+bool operator<(const Level& a, const Level& b);
+bool operator>=(const Level& a, const Level& b);
+bool operator<=(const Level& a, const Level& b);
+bool operator==(const Level& a, const Level& b);
 std::ostream& operator<<(std::ostream& out, const Level& a);
 
-template <class T>
-struct Side : public std::priority_queue<Level, std::vector<Level>, T> {
-public:
-    void deleteLevel(std::string orderId);
-    void topRemoveVolume(int volume);
-    void printTop(std::size_t num = 5);
-};
-
-using AskSide = Side<std::greater<Level>>;
-using BidSide = Side<std::less<Level>>;
-
 struct Book {
-  BidSide bidSide;
-  AskSide askSide;
-  ProductTypeEnum productType;
-  std::string product;
-  std::string stationId;
-  std::string unit;
-  std::chrono::nanoseconds expiry;
-  double aggFee;
-  double pasFee;
-  double broFee;
+	std::unordered_map<std::string, Level> bidSide;
+	std::unordered_map<std::string, Level> askSide;
+	ProductTypeEnum productType;
+	std::string product;
+	int stationId;
+	std::string unit;
+	std::chrono::nanoseconds expiry;
+	double aggFee;
+	double pasFee;
+	double broFee;
+    double bomPrice;
 
-  Book();
-  Book(ProductTypeEnum productType, std::string product, std::string stationId,
-       std::string unit, std::chrono::nanoseconds expiry, double aggFee,
-       double pasFee, double broFee);
-  void ask(Order &order);
-  void bid(Order &order);
-    void printBook(std::size_t numOrders = 10);
+	Book();
+	Book(ProductTypeEnum productType, std::string product, int stationId,
+	     std::string unit, std::chrono::nanoseconds expiry, double aggFee,
+	     double pasFee, double broFee);
+	void ask(Order& order);
+	void bid(Order& order);
+	void printBook(std::size_t numOrders = 10);
 };
 
 Book testBook(int orders = 10, bool printBook = true);
+} // namespace book

--
Gitblit v1.9.3