-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrderBookEntry.h
38 lines (33 loc) · 1.06 KB
/
OrderBookEntry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <string>
//specifying a new data type for bid,ask
enum class OrderBookType{bid,ask,unknown, sale};
//Define the class OrderBookEntry
class OrderBookEntry
{
public:
// Constructor with member initialization list
OrderBookEntry(double price,
double amount,
std::string timestamp,
std::string product,
OrderBookType orderType);
static OrderBookType stringToOrderBookType(std::string s);
static bool compareByTimestamp(OrderBookEntry& e1, OrderBookEntry& e2)
{
return e1.timestamp < e2.timestamp;
}
static bool compareByPriceAsc(OrderBookEntry& e1, OrderBookEntry& e2)
{
return e1.price < e2.price;
}
static bool compareByPriceDesc(OrderBookEntry& e1, OrderBookEntry& e2)
{
return e1.price > e2.price;
}
double price;
double amount;
std::string timestamp;
std::string product;
OrderBookType orderType;
};