-
Notifications
You must be signed in to change notification settings - Fork 162
/
Copy pathBookItem.cs
165 lines (140 loc) · 4.34 KB
/
BookItem.cs
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using VisualHFT.Commons.Model;
using VisualHFT.Commons.Helpers;
namespace VisualHFT.Model
{
public partial class BookItem : IEquatable<BookItem>, IEqualityComparer<BookItem>, IResettable, ICopiable<BookItem>, IDisposable
{
private string _Symbol;
private int _ProviderID;
private string _EntryID;
private string _LayerName;
private DateTime _LocalTimeStamp;
private double? _Price;
private DateTime _ServerTimeStamp;
private double? _Size;
private bool _IsBid;
private double? _ActiveSize;
private double? _CummulativeSize;
public BookItem()
{
}
public bool Equals(BookItem other)
{
if (other == null)
return false;
if (IsBid != other.IsBid)
return false;
if (EntryID != other.EntryID)
return false;
if (Price != other.Price)
return false;
if (Size != other.Size)
return false;
return true;
}
public bool Equals(BookItem x, BookItem y)
{
return x.Price == y.Price;
}
public int GetHashCode(BookItem obj)
{
return obj.Price.GetHashCode();
}
public void Reset()
{
Symbol = "";
ProviderID = 0;
EntryID = "";
LayerName = "";
LocalTimeStamp = DateTime.MinValue;
ServerTimeStamp = DateTime.MinValue;
Price = 0;
Size = 0;
IsBid = false;
PriceDecimalPlaces = 0;
SizeDecimalPlaces = 0;
ActiveSize = null;
CummulativeSize = 0;
}
public void CopyFrom(BookItem bookItem)
{
if (bookItem == null) throw new ArgumentNullException();
Symbol = bookItem.Symbol;
ProviderID = bookItem.ProviderID;
EntryID = bookItem.EntryID;
LayerName = bookItem.LayerName;
LocalTimeStamp = bookItem.LocalTimeStamp;
ServerTimeStamp = bookItem.ServerTimeStamp;
Price = bookItem.Price;
Size = bookItem.Size;
IsBid = bookItem.IsBid;
PriceDecimalPlaces = bookItem.PriceDecimalPlaces;
SizeDecimalPlaces = bookItem.SizeDecimalPlaces;
ActiveSize = bookItem.ActiveSize;
CummulativeSize = bookItem.CummulativeSize;
}
public int PriceDecimalPlaces { get; set; }
public int SizeDecimalPlaces { get; set; }
public string Symbol
{
get => _Symbol;
set => _Symbol = value;
}
public int ProviderID
{
get => _ProviderID;
set => _ProviderID = value;
}
public string EntryID
{
get => _EntryID;
set => _EntryID = value;
}
public string LayerName
{
get => _LayerName;
set => _LayerName = value;
}
public DateTime LocalTimeStamp
{
get => _LocalTimeStamp;
set => _LocalTimeStamp = value;
}
public double? Price
{
get => _Price;
set => _Price = value;
}
public DateTime ServerTimeStamp
{
get => _ServerTimeStamp;
set => _ServerTimeStamp = value;
}
public double? Size
{
get => _Size;
set => _Size = value;
}
public bool IsBid
{
get => _IsBid;
set => _IsBid = value;
}
public string FormattedPrice => this.Price.HasValue ? this.Price.Value.ToString("N" + PriceDecimalPlaces) : "";
public string FormattedSize => this.Size.HasValue ? HelperCommon.GetKiloFormatter(this.Size.Value, SizeDecimalPlaces) : "";
public string FormattedActiveSize => this.ActiveSize.HasValue ? HelperCommon.GetKiloFormatter(this.ActiveSize.Value) : "";
public double? CummulativeSize
{
get => _CummulativeSize;
set => _CummulativeSize = value;
}
public double? ActiveSize
{
get => _ActiveSize;
set => _ActiveSize = value;
}
public virtual void Dispose()
{
}
}
}