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