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