| | |
| | | #include <iostream> |
| | | #include <queue> |
| | | #include <string> |
| | | #include <unordered_map> |
| | | #include <vector> |
| | | |
| | | namespace book |
| | |
| | | enum ProductTypeEnum { TEST, FUTURE, SPREAD, CALL, PUT }; |
| | | |
| | | struct Order { |
| | | 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); |
| | | 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; |
| | | double 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); |
| | |
| | | std::ostream& operator<<(std::ostream& out, const Level& a); |
| | | |
| | | struct Book { |
| | | std::vector<Level> bidSide; |
| | | std::vector<Level> askSide; |
| | | ProductTypeEnum productType; |
| | | std::string product; |
| | | int 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; |
| | | |
| | | 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(); |
| | | 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); |