-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrderBookEntry.cpp
93 lines (78 loc) · 1.72 KB
/
OrderBookEntry.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <string>
#include "OrderBookEntry.h"
OrderBookEntry::OrderBookEntry(
double price,
double amount,
string timestamp,
string product,
OrderBookType orderType,
string username)
: price(price),
amount(amount),
timestamp(timestamp),
product(product),
orderType(orderType),
username(username)
{
}
double OrderBookEntry::getPrice() const
{
return price;
}
double OrderBookEntry::getAmount() const
{
return amount;
}
void OrderBookEntry::setAmount(double amount)
{
this->amount = amount;
}
string OrderBookEntry::getTimestamp() const
{
return timestamp;
}
string OrderBookEntry::getProduct() const
{
return product;
}
OrderBookType OrderBookEntry::getOrderType() const
{
return orderType;
}
void OrderBookEntry::setOrderType(OrderBookType orderType)
{
this->orderType = orderType;
}
string OrderBookEntry::getUsername() const
{
return username;
}
void OrderBookEntry::setUsername(string username)
{
this->username = username;
}
OrderBookType OrderBookEntry::stringToOrderBookType(string s)
{
if (s == "bid")
{
return OrderBookType::bid;
}
if (s == "ask")
{
return OrderBookType::ask;
}
return OrderBookType::unknown;
}
bool OrderBookEntry::compareByTimestamp(OrderBookEntry &a, OrderBookEntry &b)
{
return a.getTimestamp() < b.getTimestamp();
}
bool OrderBookEntry::compareByPriceAsc(OrderBookEntry &a, OrderBookEntry &b)
{
return a.getPrice() < b.getPrice();
}
bool OrderBookEntry::compareByPriceDesc(OrderBookEntry &a, OrderBookEntry &b)
{
return a.getPrice() > b.getPrice();
}