1
|
|
|
<?php |
2
|
|
|
namespace Carpenstar\ByBitAPI\Spot\Trade\PlaceOrder\Response; |
3
|
|
|
|
4
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper; |
5
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse; |
6
|
|
|
use Carpenstar\ByBitAPI\Spot\Trade\PlaceOrder\Interfaces\IPlaceOrderResponseInterface; |
7
|
|
|
|
8
|
|
|
class PlaceOrderResponse extends AbstractResponse implements IPlaceOrderResponseInterface |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Order ID |
12
|
|
|
* @var int $orderId |
13
|
|
|
*/ |
14
|
|
|
private ?int $orderId; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* User-generated order ID |
18
|
|
|
* @var string $orderLinkId |
19
|
|
|
*/ |
20
|
|
|
private ?string $orderLinkId; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Name of the trading pair |
24
|
|
|
* @var string $symbol |
25
|
|
|
*/ |
26
|
|
|
private ?string $symbol; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Order Creation Time |
30
|
|
|
* @var \DateTime $createTime |
31
|
|
|
*/ |
32
|
|
|
private \DateTime $createTime; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Last traded price |
36
|
|
|
* @var float $orderPrice |
37
|
|
|
*/ |
38
|
|
|
private ?float $orderPrice; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Order quantity |
42
|
|
|
* @var float $orderQty |
43
|
|
|
*/ |
44
|
|
|
private ?float $orderQty; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Order type |
48
|
|
|
* @var string $orderType |
49
|
|
|
*/ |
50
|
|
|
private ?string $orderType; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Side. BUY, SELL |
54
|
|
|
* @var string $side |
55
|
|
|
*/ |
56
|
|
|
private ?string $side; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Order status |
60
|
|
|
* @var string $status |
61
|
|
|
*/ |
62
|
|
|
private ?string $status; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Time in force |
66
|
|
|
* @var string $timeInForce |
67
|
|
|
*/ |
68
|
|
|
private ?string $timeInForce; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Account ID |
72
|
|
|
* @var string $accountId |
73
|
|
|
*/ |
74
|
|
|
private ?string $accountId; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Order category. 0:normal order by default; 1:TP/SL order |
78
|
|
|
* @var int $orderCategory |
79
|
|
|
*/ |
80
|
|
|
private ?int $orderCategory; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Trigger price. TP/SL order has this field |
84
|
|
|
* @var float $triggerPrice |
85
|
|
|
*/ |
86
|
|
|
private ?float $triggerPrice; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param array $data |
90
|
|
|
*/ |
91
|
|
|
public function __construct(array $data) |
92
|
|
|
{ |
93
|
|
|
$this |
94
|
|
|
->setOrderId($data['orderId'] ?? null) |
95
|
|
|
->setOrderLinkId($data['orderLinkId'] ?? null) |
96
|
|
|
->setSymbol($data['symbol'] ?? null) |
97
|
|
|
->setCreateTime($data['createTime'] ?? null) |
98
|
|
|
->setOrderPrice($data['orderPrice'] ?? null) |
99
|
|
|
->setOrderQty($data['orderQty'] ?? null) |
100
|
|
|
->setOrderType($data['orderType'] ?? null) |
101
|
|
|
->setSide($data['side'] ?? null) |
102
|
|
|
->setStatus($data['status'] ?? null) |
103
|
|
|
->setTimeInForce($data['timeInForce'] ?? null) |
104
|
|
|
->setAccountId($data['accountId'] ?? null) |
105
|
|
|
->setOrderCategory($data['orderCategory'] ?? null) |
106
|
|
|
->setTriggerPrice($data['triggerPrice'] ?? null); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param int $orderId |
111
|
|
|
* @return $this |
112
|
|
|
*/ |
113
|
|
|
private function setOrderId(?int $orderId): self |
114
|
|
|
{ |
115
|
|
|
$this->orderId = $orderId; |
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return int |
121
|
|
|
*/ |
122
|
|
|
public function getOrderId(): ?int |
123
|
|
|
{ |
124
|
|
|
return $this->orderId; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
private function setOrderLinkId(?string $orderLinkId): self |
128
|
|
|
{ |
129
|
|
|
$this->orderLinkId = $orderLinkId; |
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @return string |
135
|
|
|
*/ |
136
|
|
|
public function getOrderLinkId(): ?string |
137
|
|
|
{ |
138
|
|
|
return $this->orderLinkId; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param string $symbol |
143
|
|
|
* @return $this |
144
|
|
|
*/ |
145
|
|
|
private function setSymbol(?string $symbol): self |
146
|
|
|
{ |
147
|
|
|
$this->symbol = $symbol; |
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return string |
153
|
|
|
*/ |
154
|
|
|
public function getSymbol(): ?string |
155
|
|
|
{ |
156
|
|
|
return $this->symbol; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param int $createTime |
161
|
|
|
* @return $this |
162
|
|
|
*/ |
163
|
|
|
private function setCreateTime(?string $createTime): self |
164
|
|
|
{ |
165
|
|
|
if (!empty($createTime)) { |
166
|
|
|
$this->createTime = DateTimeHelper::makeFromTimestamp($createTime); |
|
|
|
|
167
|
|
|
} |
168
|
|
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @return \DateTime |
173
|
|
|
*/ |
174
|
|
|
public function getCreateTime(): \DateTime |
175
|
|
|
{ |
176
|
|
|
return $this->createTime; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @param float $orderPrice |
181
|
|
|
* @return PlaceOrderResponse |
182
|
|
|
*/ |
183
|
|
|
public function setOrderPrice(?float $orderPrice): self |
184
|
|
|
{ |
185
|
|
|
$this->orderPrice = $orderPrice; |
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @return float |
191
|
|
|
*/ |
192
|
|
|
public function getOrderPrice(): ?float |
193
|
|
|
{ |
194
|
|
|
return $this->orderPrice; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* @param float $orderQty |
199
|
|
|
* @return PlaceOrderResponse |
200
|
|
|
*/ |
201
|
|
|
private function setOrderQty(?float $orderQty): self |
202
|
|
|
{ |
203
|
|
|
$this->orderQty = $orderQty; |
204
|
|
|
return $this; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @return float |
209
|
|
|
*/ |
210
|
|
|
public function getOrderQty(): ?float |
211
|
|
|
{ |
212
|
|
|
return $this->orderQty; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @param string|null $orderType |
217
|
|
|
* @return $this |
218
|
|
|
*/ |
219
|
|
|
private function setOrderType(?string $orderType): self |
220
|
|
|
{ |
221
|
|
|
$this->orderType = $orderType; |
222
|
|
|
return $this; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @return string|null |
227
|
|
|
*/ |
228
|
|
|
public function getOrderType(): ?string |
229
|
|
|
{ |
230
|
|
|
return $this->orderType; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @return string|null |
235
|
|
|
*/ |
236
|
|
|
public function getStatus(): ?string |
237
|
|
|
{ |
238
|
|
|
return $this->status; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @param string|null $status |
243
|
|
|
* @return PlaceOrderResponse |
244
|
|
|
*/ |
245
|
|
|
private function setStatus(?string $status): self |
246
|
|
|
{ |
247
|
|
|
$this->status = $status; |
248
|
|
|
return $this; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @param string $side |
253
|
|
|
* @return PlaceOrderResponse |
254
|
|
|
*/ |
255
|
|
|
private function setSide(?string $side): self |
256
|
|
|
{ |
257
|
|
|
$this->side = $side; |
258
|
|
|
return $this; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @return string |
263
|
|
|
*/ |
264
|
|
|
public function getSide(): ?string |
265
|
|
|
{ |
266
|
|
|
return $this->side; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* @param string $timeInForce |
271
|
|
|
* @return PlaceOrderResponse |
272
|
|
|
*/ |
273
|
|
|
private function setTimeInForce(?string $timeInForce): self |
274
|
|
|
{ |
275
|
|
|
$this->timeInForce = $timeInForce; |
276
|
|
|
return $this; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* @return string |
281
|
|
|
*/ |
282
|
|
|
public function getTimeInForce(): ?string |
283
|
|
|
{ |
284
|
|
|
return $this->timeInForce; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @param string $accountId |
289
|
|
|
* @return PlaceOrderResponse |
290
|
|
|
*/ |
291
|
|
|
private function setAccountId(?string $accountId): self |
292
|
|
|
{ |
293
|
|
|
$this->accountId = $accountId; |
294
|
|
|
return $this; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @return string |
299
|
|
|
*/ |
300
|
|
|
public function getAccountId(): ?string |
301
|
|
|
{ |
302
|
|
|
return $this->accountId; |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* @param int $orderCategory |
307
|
|
|
* @return PlaceOrderResponse |
308
|
|
|
*/ |
309
|
|
|
public function setOrderCategory(?int $orderCategory): self |
310
|
|
|
{ |
311
|
|
|
$this->orderCategory = $orderCategory; |
312
|
|
|
return $this; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @return int |
317
|
|
|
*/ |
318
|
|
|
public function getOrderCategory(): ?int |
319
|
|
|
{ |
320
|
|
|
return $this->orderCategory; |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* @param float $triggerPrice |
325
|
|
|
* @return PlaceOrderResponse |
326
|
|
|
*/ |
327
|
|
|
public function setTriggerPrice(?float $triggerPrice): self |
328
|
|
|
{ |
329
|
|
|
$this->triggerPrice = $triggerPrice; |
330
|
|
|
return $this; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* @return float |
335
|
|
|
*/ |
336
|
|
|
public function getTriggerPrice(): ?float |
337
|
|
|
{ |
338
|
|
|
return $this->triggerPrice; |
339
|
|
|
} |
340
|
|
|
} |