-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuVelas.pas
181 lines (158 loc) · 4.71 KB
/
uVelas.pas
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
unit uVelas;
interface
uses Generics.Collections, System.JSON.Serializers, System.JSON.Converters, SysUtils;
{
"e": "kline", // Event type
"E": 123456789, // Event time
"s": "BNBBTC", // Symbol
"k": {
"t": 123400000, // Kline start time
"T": 123460000, // Kline close time
"s": "BNBBTC", // Symbol
"i": "1m", // Interval
"f": 100, // First trade ID
"L": 200, // Last trade ID
"o": "0.0010", // Open price
"c": "0.0020", // Close price
"h": "0.0025", // High price
"l": "0.0015", // Low price
"v": "1000", // Base asset volume
"n": 100, // Number of trades
"x": false, // Is this kline closed?
"q": "1.0000", // Quote asset volume
"V": "500", // Taker buy base asset volume
"Q": "0.500", // Taker buy quote asset volume
"B": "123456" // Ignore
}
type
[JsonSerialize(TJsonMemberSerialization.&Public)]
TDatosVela = class
private
[JsonName('t')]
FStartTime: Int64;
[JsonName('T')]
FCloseTime: Int64;
[JsonName('s')]
FSymbol: String;
[JsonName('i')]
FInterval: String;
[JsonName('o')]
FOPrice: String;
[JsonName('c')]
FCPrice: String;
[JsonName('h')]
FHPrice: String;
[JsonName('l')]
FLPrice: String;
[JsonName('v')]
FBaseAssetVolume: String;
[JsonName('n')]
FNumberOfTrades: Integer;
[JsonName('x')]
FIsClosed: Boolean;
[JsonName('q')]
FQuoteVolume: String;
[JsonName('V')]
FTakerBuyBaseVolume: String;
[JsonName('Q')]
FTakerBuyQuoteVolume: String;
FVolume: String;
public
property StartTime: Int64 read FStartTime write FStartTime;
property CloseTime: Int64 read FCloseTime write FCloseTime;
property Symbol: String read FSymbol write FSymbol;
property Interval: String read FInterval write FInterval;
property OPrice: String read FOPrice write FOPrice;
property CPrice: String read FCPrice write FCPrice;
property HPrice: String read FHPrice write FHPrice;
property LPrice: String read FLPrice write FLPrice;
property BaseAssetVolume: String read FBaseAssetVolume
write FBaseAssetVolume;
property NumberOfTrades: Integer read FNumberOfTrades write FNumberOfTrades;
property IsClosed: Boolean read FIsClosed write FIsClosed;
property QuoteVolume: String read FQuoteVolume write FQuoteVolume;
property TakerBuyBaseVolume: String read FTakerBuyBaseVolume
write FTakerBuyBaseVolume;
property TakerBuyQuoteVolume: String read FTakerBuyQuoteVolume
write FTakerBuyQuoteVolume;
property Volume: String read FVolume write FVolume;
end;
type
[JsonSerialize(TJsonMemberSerialization.&Public)]
TVela = class
private
[JsonName('e')]
FEventType: String;
[JsonName('E')]
FEventTime: Int64;
[JsonName('s')]
FSymbol: String;
[JsonName('k')]
FDatosVela: TDatosVela;
FEMA: Double;
public
property EventType: String read FEventType write FEventType;
property EventTime: Int64 read FEventTime write FEventTime;
property Symbol: String read FSymbol write FSymbol;
property DatosVela: TDatosVela read FDatosVela write FDatosVela;
property EMA: Double read FEMA write FEMA;
constructor Create;overload;
constructor Create(pOPrice, pCPrice, pHPrice, pLPrice, pVolume: String; pStartTime: Int64);overload;
destructor Destroy; override;
end;
type
TListaVelas = class
private
FVelas: TObjectList<TVela>;
public
property Velas: TObjectList<TVela> read FVelas write FVelas;
constructor Create; overload;
constructor Create(pJson: String); overload;
destructor Destroy; override;
end;
implementation
{ TListaVelas }
constructor TListaVelas.Create(pJson: String);
var
Serializer: TJsonSerializer;
begin
inherited Create;
Serializer := TJsonSerializer.Create;
try
Self := Serializer.Deserialize<TListaVelas>('');
finally
Serializer.Free;
end;
end;
destructor TListaVelas.Destroy;
begin
FVelas.Free;
inherited;
end;
constructor TListaVelas.Create;
begin
FVelas := TObjectList<TVela>.Create;
inherited;
end;
{ TVela }
constructor TVela.Create(pOPrice, pCPrice, pHPrice, pLPrice, pVolume: String; pStartTime: Int64);
begin
FDatosVela := TDatosVela.Create;
FDatosVela.OPrice := pOPrice;
FDatosVela.CPrice := pCPrice;
FDatosVela.HPrice := pHPrice;
FDatosVela.LPrice := pLPrice;
FDatosVela.Volume := pVolume;
FDatosVela.StartTime := pStartTime;
end;
constructor TVela.Create;
begin
inherited;
FDatosVela := TDatosVela.Create;
end;
destructor TVela.Destroy;
begin
FDatosVela.Free;
inherited;
end;
end.