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 { |
16b655
|
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 { |
16b655
|
28 |
double price; |
JG |
29 |
int volume; |
|
30 |
OrderSideEnum side; |
|
31 |
double timestamp; |
|
32 |
std::string id; |
bb2353
|
33 |
|
16b655
|
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 { |
16b655
|
45 |
std::vector<Level> bidSide; |
JG |
46 |
std::vector<Level> askSide; |
|
47 |
ProductTypeEnum productType; |
|
48 |
std::string product; |
|
49 |
std::string stationId; |
|
50 |
std::string unit; |
|
51 |
std::chrono::nanoseconds expiry; |
|
52 |
double aggFee; |
|
53 |
double pasFee; |
|
54 |
double broFee; |
bb2353
|
55 |
|
16b655
|
56 |
Book(); |
JG |
57 |
Book(ProductTypeEnum productType, std::string product, |
|
58 |
std::string stationId, std::string unit, |
|
59 |
std::chrono::nanoseconds expiry, double aggFee, double pasFee, |
|
60 |
double broFee); |
|
61 |
void ask(Order& order); |
|
62 |
void bid(Order& order); |
127d5a
|
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 |