1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Carpenstar\ByBitAPI\Spot\Trade\OrderHistory\Response; |
4
|
|
|
|
5
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper; |
6
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse; |
7
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\OrderHistory\Interfaces\IOrderHistoryResponseItemInterface; |
8
|
|
|
|
9
|
|
|
class OrderHistoryResponseItem extends AbstractResponse implements IOrderHistoryResponseItemInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Account ID |
13
|
|
|
* @var int $accountId |
14
|
|
|
*/ |
15
|
|
|
private int $accountId; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Name of the trading pair |
19
|
|
|
* @var string $symbol |
20
|
|
|
*/ |
21
|
|
|
private string $symbol; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* User-generated order ID |
25
|
|
|
* @var string $orderLinkId |
26
|
|
|
*/ |
27
|
|
|
private string $orderLinkId; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Order ID |
31
|
|
|
* @var int $orderId |
32
|
|
|
*/ |
33
|
|
|
private int $orderId; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Last traded price |
37
|
|
|
* @var float $orderPrice |
38
|
|
|
*/ |
39
|
|
|
private float $orderPrice; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Order quantity |
43
|
|
|
* @var float $orderQty |
44
|
|
|
*/ |
45
|
|
|
private float $orderQty; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Executed quantity |
49
|
|
|
* @var float $execQty |
50
|
|
|
*/ |
51
|
|
|
private float $execQty; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Total order quantity |
55
|
|
|
* @var float $cummulativeQuoteQty |
56
|
|
|
*/ |
57
|
|
|
private float $cummulativeQuoteQty; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Average filled price |
61
|
|
|
* @var float $avgPrice |
62
|
|
|
*/ |
63
|
|
|
private float $avgPrice; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Order status |
67
|
|
|
* @var string $status |
68
|
|
|
*/ |
69
|
|
|
private string $status; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Time in force |
73
|
|
|
* @var string $timeInForce |
74
|
|
|
*/ |
75
|
|
|
private string $timeInForce; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Order type |
79
|
|
|
* @var string $orderType |
80
|
|
|
*/ |
81
|
|
|
private string $orderType; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Side. BUY, SELL |
85
|
|
|
* @var string $side |
86
|
|
|
*/ |
87
|
|
|
private string $side; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Stop price |
91
|
|
|
* @var float $stopPrice |
92
|
|
|
*/ |
93
|
|
|
private float $stopPrice; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Order created time in the match engine |
97
|
|
|
* @var \DateTime $createTime; |
98
|
|
|
*/ |
99
|
|
|
private \DateTime $createTime; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Last time order was updated |
103
|
|
|
* @var \DateTime $updateTime |
104
|
|
|
*/ |
105
|
|
|
private \DateTime $updateTime; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Is working. 0:valid, 1:invalid |
109
|
|
|
* @var int $isWorking |
110
|
|
|
*/ |
111
|
|
|
private int $isWorking; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Order category. 0:normal order; 1:TP/SL order. TP/SL order has this field |
115
|
|
|
* @var int $orderCategory |
116
|
|
|
*/ |
117
|
|
|
private int $orderCategory; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Trigger price. TP/SL order has this field |
121
|
|
|
* @var float $triggerPrice |
122
|
|
|
*/ |
123
|
|
|
private ?float $triggerPrice; |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param array $data |
127
|
|
|
*/ |
128
|
|
|
public function __construct(array $data) |
129
|
|
|
{ |
130
|
|
|
$this |
131
|
|
|
->setAccountId($data['accountId']) |
132
|
|
|
->setSymbol($data['symbol']) |
133
|
|
|
->setOrderLinkId($data['orderLinkId']) |
134
|
|
|
->setOrderId($data['orderId']) |
135
|
|
|
->setOrderId($data['orderPrice']) |
136
|
|
|
->setOrderQty($data['orderQty']) |
137
|
|
|
->setExecQty($data['execQty']) |
138
|
|
|
->setCummulativeQuoteQty($data['cummulativeQuoteQty']) |
139
|
|
|
->setAvgPrice($data['avgPrice']) |
140
|
|
|
->setStatus($data['status']) |
141
|
|
|
->setTimeInForce($data['timeInForce']) |
142
|
|
|
->setOrderType($data['orderType']) |
143
|
|
|
->setSide($data['side']) |
144
|
|
|
->setStopPrice($data['stopPrice']) |
145
|
|
|
->setCreateTime($data['createTime']) |
146
|
|
|
->setUpdateTime($data['updateTime']) |
147
|
|
|
->setIsWorking($data['isWorking']) |
148
|
|
|
->setOrderCategory($data['orderCategory'] ?? 0) |
149
|
|
|
->setOrderPrice($data['orderPrice']) |
150
|
|
|
->setTriggerPrice($data['triggerPrice'] ?? null); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param int $accountId |
155
|
|
|
* @return OrderHistoryResponse |
156
|
|
|
*/ |
157
|
|
|
public function setAccountId(int $accountId): self |
158
|
|
|
{ |
159
|
|
|
$this->accountId = $accountId; |
160
|
|
|
return $this; |
|
|
|
|
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return int |
165
|
|
|
*/ |
166
|
|
|
public function getAccountId(): int |
167
|
|
|
{ |
168
|
|
|
return $this->accountId; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param string $symbol |
173
|
|
|
* @return OrderHistoryResponse |
174
|
|
|
*/ |
175
|
|
|
public function setSymbol(string $symbol): self |
176
|
|
|
{ |
177
|
|
|
$this->symbol = $symbol; |
178
|
|
|
return $this; |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @return string |
183
|
|
|
*/ |
184
|
|
|
public function getSymbol(): string |
185
|
|
|
{ |
186
|
|
|
return $this->symbol; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @param string $orderLinkId |
191
|
|
|
* @return OrderHistoryResponse |
192
|
|
|
*/ |
193
|
|
|
public function setOrderLinkId(string $orderLinkId): self |
194
|
|
|
{ |
195
|
|
|
$this->orderLinkId = $orderLinkId; |
196
|
|
|
return $this; |
|
|
|
|
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @return string |
201
|
|
|
*/ |
202
|
|
|
public function getOrderLinkId(): string |
203
|
|
|
{ |
204
|
|
|
return $this->orderLinkId; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @param int $orderId |
209
|
|
|
* @return OrderHistoryResponse |
210
|
|
|
*/ |
211
|
|
|
public function setOrderId(int $orderId): self |
212
|
|
|
{ |
213
|
|
|
$this->orderId = $orderId; |
214
|
|
|
return $this; |
|
|
|
|
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return int |
219
|
|
|
*/ |
220
|
|
|
public function getOrderId(): int |
221
|
|
|
{ |
222
|
|
|
return $this->orderId; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @param float $orderPrice |
227
|
|
|
* @return OrderHistoryResponse |
228
|
|
|
*/ |
229
|
|
|
public function setOrderPrice(float $orderPrice): self |
230
|
|
|
{ |
231
|
|
|
$this->orderPrice = $orderPrice; |
232
|
|
|
return $this; |
|
|
|
|
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return float |
237
|
|
|
*/ |
238
|
|
|
public function getOrderPrice(): float |
239
|
|
|
{ |
240
|
|
|
return $this->orderPrice; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param float $orderQty |
245
|
|
|
* @return OrderHistoryResponse |
246
|
|
|
*/ |
247
|
|
|
public function setOrderQty(float $orderQty): self |
248
|
|
|
{ |
249
|
|
|
$this->orderQty = $orderQty; |
250
|
|
|
return $this; |
|
|
|
|
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @return float |
255
|
|
|
*/ |
256
|
|
|
public function getOrderQty(): float |
257
|
|
|
{ |
258
|
|
|
return $this->orderQty; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @param float $execQty |
263
|
|
|
* @return OrderHistoryResponse |
264
|
|
|
*/ |
265
|
|
|
public function setExecQty(float $execQty): self |
266
|
|
|
{ |
267
|
|
|
$this->execQty = $execQty; |
268
|
|
|
return $this; |
|
|
|
|
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* @return float |
273
|
|
|
*/ |
274
|
|
|
public function getExecQty(): float |
275
|
|
|
{ |
276
|
|
|
return $this->execQty; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* @param float $cummulativeQuoteQty |
281
|
|
|
* @return OrderHistoryResponse |
282
|
|
|
*/ |
283
|
|
|
public function setCummulativeQuoteQty(float $cummulativeQuoteQty): self |
284
|
|
|
{ |
285
|
|
|
$this->cummulativeQuoteQty = $cummulativeQuoteQty; |
286
|
|
|
return $this; |
|
|
|
|
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* @return float |
291
|
|
|
*/ |
292
|
|
|
public function getCummulativeQuoteQty(): float |
293
|
|
|
{ |
294
|
|
|
return $this->cummulativeQuoteQty; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @param float $avgPrice |
299
|
|
|
* @return OrderHistoryResponse |
300
|
|
|
*/ |
301
|
|
|
public function setAvgPrice(float $avgPrice): self |
302
|
|
|
{ |
303
|
|
|
$this->avgPrice = $avgPrice; |
304
|
|
|
return $this; |
|
|
|
|
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @return float |
309
|
|
|
*/ |
310
|
|
|
public function getAvgPrice(): float |
311
|
|
|
{ |
312
|
|
|
return $this->avgPrice; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @param string $status |
317
|
|
|
* @return OrderHistoryResponse |
318
|
|
|
*/ |
319
|
|
|
public function setStatus(string $status): self |
320
|
|
|
{ |
321
|
|
|
$this->status = $status; |
322
|
|
|
return $this; |
|
|
|
|
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* @return string |
327
|
|
|
*/ |
328
|
|
|
public function getStatus(): string |
329
|
|
|
{ |
330
|
|
|
return $this->status; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* @param string $timeInForce |
335
|
|
|
* @return OrderHistoryResponse |
336
|
|
|
*/ |
337
|
|
|
public function setTimeInForce(string $timeInForce): self |
338
|
|
|
{ |
339
|
|
|
$this->timeInForce = $timeInForce; |
340
|
|
|
return $this; |
|
|
|
|
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* @return string |
345
|
|
|
*/ |
346
|
|
|
public function getTimeInForce(): string |
347
|
|
|
{ |
348
|
|
|
return $this->timeInForce; |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* @param string $orderType |
353
|
|
|
* @return OrderHistoryResponse |
354
|
|
|
*/ |
355
|
|
|
public function setOrderType(string $orderType): self |
356
|
|
|
{ |
357
|
|
|
$this->orderType = $orderType; |
358
|
|
|
return $this; |
|
|
|
|
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* @return string |
363
|
|
|
*/ |
364
|
|
|
public function getOrderType(): string |
365
|
|
|
{ |
366
|
|
|
return $this->orderType; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* @param string $side |
371
|
|
|
* @return OrderHistoryResponse |
372
|
|
|
*/ |
373
|
|
|
public function setSide(string $side): self |
374
|
|
|
{ |
375
|
|
|
$this->side = $side; |
376
|
|
|
return $this; |
|
|
|
|
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* @return string |
381
|
|
|
*/ |
382
|
|
|
public function getSide(): string |
383
|
|
|
{ |
384
|
|
|
return $this->side; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @param float $stopPrice |
389
|
|
|
* @return OrderHistoryResponse |
390
|
|
|
*/ |
391
|
|
|
public function setStopPrice(float $stopPrice): self |
392
|
|
|
{ |
393
|
|
|
$this->stopPrice = $stopPrice; |
394
|
|
|
return $this; |
|
|
|
|
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* @return float |
399
|
|
|
*/ |
400
|
|
|
public function getStopPrice(): float |
401
|
|
|
{ |
402
|
|
|
return $this->stopPrice; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* @param int $createTime |
407
|
|
|
* @return OrderHistoryResponse |
408
|
|
|
*/ |
409
|
|
|
public function setCreateTime(int $createTime): self |
410
|
|
|
{ |
411
|
|
|
$this->createTime = DateTimeHelper::makeFromTimestamp($createTime); |
412
|
|
|
return $this; |
|
|
|
|
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
/** |
416
|
|
|
* @return \DateTime |
417
|
|
|
*/ |
418
|
|
|
public function getCreateTime(): \DateTime |
419
|
|
|
{ |
420
|
|
|
return $this->createTime; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
/** |
424
|
|
|
* @param int $updateTime |
425
|
|
|
* @return OrderHistoryResponse |
426
|
|
|
*/ |
427
|
|
|
public function setUpdateTime(int $updateTime): self |
428
|
|
|
{ |
429
|
|
|
$this->updateTime = DateTimeHelper::makeFromTimestamp($updateTime); |
430
|
|
|
return $this; |
|
|
|
|
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* @return DateTime |
|
|
|
|
435
|
|
|
*/ |
436
|
|
|
public function getUpdateTime(): \DateTime |
437
|
|
|
{ |
438
|
|
|
return $this->updateTime; |
|
|
|
|
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
/** |
442
|
|
|
* @param int $isWorking |
443
|
|
|
* @return OrderHistoryResponse |
444
|
|
|
*/ |
445
|
|
|
public function setIsWorking(int $isWorking): self |
446
|
|
|
{ |
447
|
|
|
$this->isWorking = $isWorking; |
448
|
|
|
return $this; |
|
|
|
|
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* @return int |
453
|
|
|
*/ |
454
|
|
|
public function getIsWorking(): int |
455
|
|
|
{ |
456
|
|
|
return $this->isWorking; |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* @param int $orderCategory |
461
|
|
|
* @return OrderHistoryResponse |
462
|
|
|
*/ |
463
|
|
|
public function setOrderCategory(int $orderCategory): self |
464
|
|
|
{ |
465
|
|
|
$this->orderCategory = $orderCategory; |
466
|
|
|
return $this; |
|
|
|
|
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* @return int |
471
|
|
|
*/ |
472
|
|
|
public function getOrderCategory(): int |
473
|
|
|
{ |
474
|
|
|
return $this->orderCategory; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* @param float $triggerPrice |
479
|
|
|
* @return OrderHistoryResponse |
480
|
|
|
*/ |
481
|
|
|
public function setTriggerPrice(?float $triggerPrice): self |
482
|
|
|
{ |
483
|
|
|
$this->triggerPrice = $triggerPrice; |
484
|
|
|
return $this; |
|
|
|
|
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* @return float |
489
|
|
|
*/ |
490
|
|
|
public function getTriggerPrice(): ?float |
491
|
|
|
{ |
492
|
|
|
return $this->triggerPrice; |
493
|
|
|
} |
494
|
|
|
} |
495
|
|
|
|