-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathorder_base_t.cpp
85 lines (68 loc) · 2.27 KB
/
order_base_t.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
#include "order_base_t.h"
#include "symbol_base_t.h"
namespace trading
{
//-------------------------------------------------------------------
//-------------------------------------------------------------------
int order_base_t::s_counter = 0;
//-------------------------------------------------------------------
//-------------------------------------------------------------------
order_base_t::order_base_t(const symbol_base_t& symbol,
order_dir_t dir,
double price,
vol_t volume,
const ptime& datetime) :
m_id{++s_counter},
m_symbol(symbol),
m_dir{dir},
m_price{price},
m_volume{volume},
m_datetime{datetime}
{
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
order_base_t::order_base_t(const symbol_base_t &symbol) :
order_base_t{symbol, order_dir_t::bid, 0.0, 0, ptime{min_date_time}}
{
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
order_base_t::~order_base_t()
{
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
bool order_base_t::bids_compare(const order_base_t& bid1, const order_base_t& bid2)
{
if (bid1.price() > bid2.price())
return true;
else if (bid1.price() == bid2.price())
{
if (bid1.datetime() < bid2.datetime())
return true;
else
return false;
}
else
return false;
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
bool order_base_t::asks_compare(const order_base_t& ask1, const order_base_t& ask2)
{
if (ask1.price() < ask2.price())
return true;
else if (ask1.price() == ask2.price())
{
if (ask1.datetime() < ask2.datetime())
return true;
else
return false;
}
else
return false;
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
}