1
|
|
|
<?php |
2
|
|
|
namespace Carpenstar\ByBitAPI\Spot\Trade\TradeHistory\Response; |
3
|
|
|
|
4
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper; |
5
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\ResponseEntity; |
6
|
|
|
|
7
|
|
|
class TradeHistoryResponse extends ResponseEntity |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Name of the trading pair |
11
|
|
|
* @var string $symbol |
12
|
|
|
*/ |
13
|
|
|
private string $symbol; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Irrelevant for API usage. This field reflects the "Transaction ID" from the Trade History section of the website |
17
|
|
|
* @var int $id |
18
|
|
|
*/ |
19
|
|
|
private int $id; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Order ID |
23
|
|
|
* @var int $orderId |
24
|
|
|
*/ |
25
|
|
|
private int $orderId; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The ID for the trade |
29
|
|
|
* @var int $tradeId |
30
|
|
|
*/ |
31
|
|
|
private int $tradeId; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Last traded price |
35
|
|
|
* @var float $orderPrice |
36
|
|
|
*/ |
37
|
|
|
private float $orderPrice; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Order quantity |
41
|
|
|
* @var float $orderQty |
42
|
|
|
*/ |
43
|
|
|
private float $orderQty; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Trading fee (for a single fill) |
47
|
|
|
* @var float $execFee |
48
|
|
|
*/ |
49
|
|
|
private float $execFee; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Fee Token ID |
53
|
|
|
* @var string $feeTokenId |
54
|
|
|
*/ |
55
|
|
|
private string $feeTokenId; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Order created time in the match engine |
59
|
|
|
* @var \DateTime $creatTime |
60
|
|
|
*/ |
61
|
|
|
private \DateTime $creatTime; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* 0:Buyer, 1:Seller |
65
|
|
|
* @var int $isBuyer |
66
|
|
|
*/ |
67
|
|
|
private int $isBuyer; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* 0:Maker, 1:Taker |
71
|
|
|
* @var int $isMaker |
72
|
|
|
*/ |
73
|
|
|
private int $isMaker; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Order ID of the opponent trader |
77
|
|
|
* @var int $matchOrderId |
78
|
|
|
*/ |
79
|
|
|
private int $matchOrderId; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Maker rebate |
83
|
|
|
* @var int $makerRebate |
84
|
|
|
*/ |
85
|
|
|
private int $makerRebate; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Order execution time |
89
|
|
|
* @var \DateTime $executionTime |
90
|
|
|
*/ |
91
|
|
|
private \DateTime $executionTime; |
92
|
|
|
|
93
|
|
|
public function __construct(array $data) |
94
|
|
|
{ |
95
|
|
|
$this |
96
|
|
|
->setOrderId($data['orderId']) |
97
|
|
|
->setOrderQty($data['orderQty']) |
98
|
|
|
->setSymbol($data['symbol']) |
99
|
|
|
->setOrderPrice($data['orderPrice']) |
100
|
|
|
->setCreatTime($data['creatTime']) |
101
|
|
|
->setExecFee($data['execFee']) |
102
|
|
|
->setExecutionTime($data['executionTime']) |
103
|
|
|
->setFeeTokenId($data['feeTokenId']) |
104
|
|
|
->setIsBuyer($data['isBuyer']) |
105
|
|
|
->setIsMaker($data['isMaker']) |
106
|
|
|
->setMakerRebate($data['makerRebate']) |
107
|
|
|
->setMatchOrderId($data['matchOrderId']) |
108
|
|
|
->setTradeId($data['tradeId']) |
109
|
|
|
->setId($data['id']); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return int |
114
|
|
|
*/ |
115
|
|
|
public function getOrderId(): int |
116
|
|
|
{ |
117
|
|
|
return $this->orderId; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param int $orderId |
122
|
|
|
* @return TradeHistoryResponse |
123
|
|
|
*/ |
124
|
|
|
private function setOrderId(int $orderId): self |
125
|
|
|
{ |
126
|
|
|
$this->orderId = $orderId; |
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return string |
132
|
|
|
*/ |
133
|
|
|
public function getSymbol(): string |
134
|
|
|
{ |
135
|
|
|
return $this->symbol; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param string $symbol |
140
|
|
|
* @return TradeHistoryResponse |
141
|
|
|
*/ |
142
|
|
|
private function setSymbol(string $symbol): self |
143
|
|
|
{ |
144
|
|
|
$this->symbol = $symbol; |
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return float |
150
|
|
|
*/ |
151
|
|
|
public function getOrderQty(): float |
152
|
|
|
{ |
153
|
|
|
return $this->orderQty; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param float $orderQty |
158
|
|
|
* @return TradeHistoryResponse |
159
|
|
|
*/ |
160
|
|
|
private function setOrderQty(float $orderQty): self |
161
|
|
|
{ |
162
|
|
|
$this->orderQty = $orderQty; |
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return float |
168
|
|
|
*/ |
169
|
|
|
public function getOrderPrice(): float |
170
|
|
|
{ |
171
|
|
|
return $this->orderPrice; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param float $orderPrice |
176
|
|
|
* @return TradeHistoryResponse |
177
|
|
|
*/ |
178
|
|
|
private function setOrderPrice(float $orderPrice): self |
179
|
|
|
{ |
180
|
|
|
$this->orderPrice = $orderPrice; |
181
|
|
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return \DateTime |
186
|
|
|
*/ |
187
|
|
|
public function getCreatTime(): \DateTime |
188
|
|
|
{ |
189
|
|
|
return $this->creatTime; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param int $creatTime |
194
|
|
|
* @return TradeHistoryResponse |
195
|
|
|
*/ |
196
|
|
|
private function setCreatTime(int $creatTime): self |
197
|
|
|
{ |
198
|
|
|
$this->creatTime = DateTimeHelper::makeFromTimestamp($creatTime); |
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @return float |
204
|
|
|
*/ |
205
|
|
|
public function getExecFee(): float |
206
|
|
|
{ |
207
|
|
|
return $this->execFee; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @param float $execFee |
212
|
|
|
* @return TradeHistoryResponse |
213
|
|
|
*/ |
214
|
|
|
private function setExecFee(float $execFee): self |
215
|
|
|
{ |
216
|
|
|
$this->execFee = $execFee; |
217
|
|
|
return $this; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return \DateTime |
222
|
|
|
*/ |
223
|
|
|
public function getExecutionTime(): \DateTime |
224
|
|
|
{ |
225
|
|
|
return $this->executionTime; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param int $executionTime |
230
|
|
|
* @return TradeHistoryResponse |
231
|
|
|
*/ |
232
|
|
|
private function setExecutionTime(int $executionTime): self |
233
|
|
|
{ |
234
|
|
|
$this->executionTime = DateTimeHelper::makeFromTimestamp($executionTime); |
235
|
|
|
return $this; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @return string |
240
|
|
|
*/ |
241
|
|
|
public function getFeeTokenId(): string |
242
|
|
|
{ |
243
|
|
|
return $this->feeTokenId; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @param string $feeTokenId |
248
|
|
|
* @return TradeHistoryResponse |
249
|
|
|
*/ |
250
|
|
|
private function setFeeTokenId(string $feeTokenId): self |
251
|
|
|
{ |
252
|
|
|
$this->feeTokenId = $feeTokenId; |
253
|
|
|
return $this; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @return int |
258
|
|
|
*/ |
259
|
|
|
public function getId(): int |
260
|
|
|
{ |
261
|
|
|
return $this->id; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @param int $id |
266
|
|
|
* @return TradeHistoryResponse |
267
|
|
|
*/ |
268
|
|
|
private function setId(int $id): self |
269
|
|
|
{ |
270
|
|
|
$this->id = $id; |
271
|
|
|
return $this; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @return int |
276
|
|
|
*/ |
277
|
|
|
public function getIsBuyer(): int |
278
|
|
|
{ |
279
|
|
|
return $this->isBuyer; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* @param int $isBuyer |
284
|
|
|
* @return TradeHistoryResponse |
285
|
|
|
*/ |
286
|
|
|
private function setIsBuyer(int $isBuyer): self |
287
|
|
|
{ |
288
|
|
|
$this->isBuyer = $isBuyer; |
289
|
|
|
return $this; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @return int |
294
|
|
|
*/ |
295
|
|
|
public function getIsMaker(): int |
296
|
|
|
{ |
297
|
|
|
return $this->isMaker; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @param int $isMaker |
302
|
|
|
* @return TradeHistoryResponse |
303
|
|
|
*/ |
304
|
|
|
private function setIsMaker(int $isMaker): self |
305
|
|
|
{ |
306
|
|
|
$this->isMaker = $isMaker; |
307
|
|
|
return $this; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* @return int |
312
|
|
|
*/ |
313
|
|
|
public function getMakerRebate(): int |
314
|
|
|
{ |
315
|
|
|
return $this->makerRebate; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* @param int $makerRebate |
320
|
|
|
* @return TradeHistoryResponse |
321
|
|
|
*/ |
322
|
|
|
private function setMakerRebate(int $makerRebate): self |
323
|
|
|
{ |
324
|
|
|
$this->makerRebate = $makerRebate; |
325
|
|
|
return $this; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* @return int |
330
|
|
|
*/ |
331
|
|
|
public function getMatchOrderId(): int |
332
|
|
|
{ |
333
|
|
|
return $this->matchOrderId; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* @param int $matchOrderId |
338
|
|
|
* @return TradeHistoryResponse |
339
|
|
|
*/ |
340
|
|
|
private function setMatchOrderId(int $matchOrderId): self |
341
|
|
|
{ |
342
|
|
|
$this->matchOrderId = $matchOrderId; |
343
|
|
|
return $this; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* @return int |
348
|
|
|
*/ |
349
|
|
|
public function getTradeId(): int |
350
|
|
|
{ |
351
|
|
|
return $this->tradeId; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* @param int $tradeId |
356
|
|
|
* @return TradeHistoryResponse |
357
|
|
|
*/ |
358
|
|
|
private function setTradeId(int $tradeId): self |
359
|
|
|
{ |
360
|
|
|
$this->tradeId = $tradeId; |
361
|
|
|
return $this; |
362
|
|
|
} |
363
|
|
|
} |