Joel Grunbaum
2022-01-10 2c515f0de70ad675b5f5d25b6a496d67d8dc0463
commit | author | age
bb2353 1 #pragma once
JG 2
16b655 3 #include <algorithm>
bb2353 4 #include <chrono>
127d5a 5 #include <cstddef>
bb2353 6 #include <iostream>
JG 7 #include <queue>
8 #include <string>
9 #include <vector>
10
16b655 11 namespace book
JG 12 {
bb2353 13 enum OrderSideEnum { Buy, Sell };
JG 14 enum ProductTypeEnum { TEST, FUTURE, SPREAD, CALL, PUT };
15
16 struct Order {
2c515f 17     double price;
JG 18     OrderSideEnum side;
19     int remaining_volume;
20     int filled_volume;
21     double timestamp;
22     std::string id;
23     Order(double price, OrderSideEnum side, int volume, double timestamp,
24           std::string id);
bb2353 25 };
JG 26
27 struct Level {
2c515f 28     double price;
JG 29     int volume;
30     OrderSideEnum side;
31     double timestamp;
32     std::string id;
bb2353 33
2c515f 34     Level(Order& order);
bb2353 35 };
JG 36
16b655 37 bool operator>(const Level& a, const Level& b);
JG 38 bool operator<(const Level& a, const Level& b);
39 bool operator>=(const Level& a, const Level& b);
40 bool operator<=(const Level& a, const Level& b);
41 bool operator==(const Level& a, const Level& b);
127d5a 42 std::ostream& operator<<(std::ostream& out, const Level& a);
bb2353 43
JG 44 struct Book {
2c515f 45     std::vector<Level> bidSide;
JG 46     std::vector<Level> askSide;
47     ProductTypeEnum productType;
48     std::string product;
49     int stationId;
50     std::string unit;
51     std::chrono::nanoseconds expiry;
52     double aggFee;
53     double pasFee;
54     double broFee;
bb2353 55
2c515f 56     Book();
JG 57     Book(ProductTypeEnum productType, std::string product, int stationId,
58          std::string unit, std::chrono::nanoseconds expiry, double aggFee,
59          double pasFee, double broFee);
60     void ask(Order& order);
61     void bid(Order& order);
62     void printBook(std::size_t numOrders = 10);
bb2353 63 };
JG 64
65 Book testBook(int orders = 10, bool printBook = true);
16b655 66 } // namespace book