|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Response; |
|
4
|
|
|
|
|
5
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper; |
|
6
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse; |
|
7
|
|
|
use Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Interfaces\IGetClosedPnLResponseItemInterface; |
|
8
|
|
|
|
|
9
|
|
|
class GetClosedPnLResponseItem extends AbstractResponse implements IGetClosedPnLResponseItemInterface |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Symbol name |
|
13
|
|
|
* @var string $symbol |
|
14
|
|
|
*/ |
|
15
|
|
|
private string $symbol; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Order Id |
|
19
|
|
|
* @var string $orderId |
|
20
|
|
|
*/ |
|
21
|
|
|
private string $orderId; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Sell, Buy, Side |
|
25
|
|
|
* @var string $side |
|
26
|
|
|
*/ |
|
27
|
|
|
private string $side; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Order qty |
|
31
|
|
|
* @var float $qty |
|
32
|
|
|
*/ |
|
33
|
|
|
private float $qty; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* leverage |
|
37
|
|
|
* @var float $leverage |
|
38
|
|
|
*/ |
|
39
|
|
|
private float $leverage; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Order price |
|
43
|
|
|
* @var float $orderPrice |
|
44
|
|
|
*/ |
|
45
|
|
|
private float $orderPrice; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Order type. Market,Limit |
|
49
|
|
|
* @var string $orderType |
|
50
|
|
|
*/ |
|
51
|
|
|
private string $orderType; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Exec type |
|
55
|
|
|
* @var string $execType |
|
56
|
|
|
*/ |
|
57
|
|
|
private string $execType; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Closed size |
|
61
|
|
|
* @var float $closedSize |
|
62
|
|
|
*/ |
|
63
|
|
|
private float $closedSize; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Cumulated entry position value |
|
67
|
|
|
* @var float $cumEntryValue |
|
68
|
|
|
*/ |
|
69
|
|
|
private float $cumEntryValue; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Average entry price |
|
73
|
|
|
* @var float $avgEntryPrice |
|
74
|
|
|
*/ |
|
75
|
|
|
private float $avgEntryPrice; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Cumulated exit position value |
|
79
|
|
|
* @var float $cumExitValue |
|
80
|
|
|
*/ |
|
81
|
|
|
private float $cumExitValue; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Average exit price |
|
85
|
|
|
* @var float $avgExitPrice |
|
86
|
|
|
*/ |
|
87
|
|
|
private float $avgExitPrice; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Closed PnL |
|
91
|
|
|
* @var float $closedPnl |
|
92
|
|
|
*/ |
|
93
|
|
|
private float $closedPnl; |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* The number of fills in a single order |
|
97
|
|
|
* @var int $fillCount |
|
98
|
|
|
*/ |
|
99
|
|
|
private int $fillCount; |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* The created time (ms) |
|
103
|
|
|
* @var \DateTime $createdAt |
|
104
|
|
|
*/ |
|
105
|
|
|
private \DateTime $createdAt; |
|
106
|
|
|
|
|
107
|
|
|
private \DateTime $createdTime; |
|
108
|
|
|
|
|
109
|
|
|
private \DateTime $updatedTime; |
|
110
|
|
|
|
|
111
|
|
|
public function __construct(array $data) |
|
112
|
|
|
{ |
|
113
|
|
|
$this->symbol = $data['symbol']; |
|
114
|
|
|
$this->orderId = $data['orderId']; |
|
115
|
|
|
$this->side = $data['side']; |
|
116
|
|
|
$this->qty = $data['qty']; |
|
117
|
|
|
$this->leverage = $data['leverage']; |
|
118
|
|
|
$this->orderPrice = $data['orderPrice']; |
|
119
|
|
|
$this->execType = $data['execType']; |
|
120
|
|
|
$this->orderType = $data['orderType']; |
|
121
|
|
|
$this->closedSize = $data['closedSize']; |
|
122
|
|
|
$this->cumEntryValue = $data['cumEntryValue']; |
|
123
|
|
|
$this->avgEntryPrice = $data['avgEntryPrice']; |
|
124
|
|
|
$this->cumExitValue = $data['cumExitValue']; |
|
125
|
|
|
$this->avgExitPrice = $data['avgExitPrice']; |
|
126
|
|
|
$this->closedPnl = $data['closedPnl']; |
|
127
|
|
|
$this->fillCount = $data['fillCount']; |
|
128
|
|
|
$this->createdAt = DateTimeHelper::makeFromTimestamp($data['createdAt']); |
|
129
|
|
|
$this->createdTime = DateTimeHelper::makeFromTimestamp($data['createdTime']); |
|
130
|
|
|
$this->updatedTime = DateTimeHelper::makeFromTimestamp($data['updatedTime']); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @return string |
|
135
|
|
|
*/ |
|
136
|
|
|
public function getSymbol(): string |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->symbol; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @return string |
|
143
|
|
|
*/ |
|
144
|
|
|
public function getOrderId(): string |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->orderId; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @return string |
|
151
|
|
|
*/ |
|
152
|
|
|
public function getSide(): string |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->side; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @return float |
|
159
|
|
|
*/ |
|
160
|
|
|
public function getQty(): float |
|
161
|
|
|
{ |
|
162
|
|
|
return $this->qty; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* @return float |
|
167
|
|
|
*/ |
|
168
|
|
|
public function getLeverage(): float |
|
169
|
|
|
{ |
|
170
|
|
|
return $this->leverage; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @return float |
|
175
|
|
|
*/ |
|
176
|
|
|
public function getOrderPrice(): float |
|
177
|
|
|
{ |
|
178
|
|
|
return $this->orderPrice; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* @return string |
|
183
|
|
|
*/ |
|
184
|
|
|
public function getOrderType(): string |
|
185
|
|
|
{ |
|
186
|
|
|
return $this->orderType; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @return string |
|
191
|
|
|
*/ |
|
192
|
|
|
public function getExecType(): string |
|
193
|
|
|
{ |
|
194
|
|
|
return $this->execType; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* @return float |
|
199
|
|
|
*/ |
|
200
|
|
|
public function getClosedSize(): float |
|
201
|
|
|
{ |
|
202
|
|
|
return $this->closedSize; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* @return float |
|
208
|
|
|
*/ |
|
209
|
|
|
public function getCumEntryValue(): float |
|
210
|
|
|
{ |
|
211
|
|
|
return $this->cumEntryValue; |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
/** |
|
215
|
|
|
* @return float |
|
216
|
|
|
*/ |
|
217
|
|
|
public function getAvgEntryPrice(): float |
|
218
|
|
|
{ |
|
219
|
|
|
return $this->avgEntryPrice; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* @return float |
|
224
|
|
|
*/ |
|
225
|
|
|
public function getCumExitValue(): float |
|
226
|
|
|
{ |
|
227
|
|
|
return $this->cumExitValue; |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* @return float |
|
232
|
|
|
*/ |
|
233
|
|
|
public function getAvgExitPrice(): float |
|
234
|
|
|
{ |
|
235
|
|
|
return $this->avgExitPrice; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* @return float |
|
240
|
|
|
*/ |
|
241
|
|
|
public function getClosedPnl(): float |
|
242
|
|
|
{ |
|
243
|
|
|
return $this->closedPnl; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* @return int |
|
248
|
|
|
*/ |
|
249
|
|
|
public function getFillCount(): int |
|
250
|
|
|
{ |
|
251
|
|
|
return $this->fillCount; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* @return \DateTime |
|
256
|
|
|
*/ |
|
257
|
|
|
public function getCreatedAt(): \DateTime |
|
258
|
|
|
{ |
|
259
|
|
|
return $this->createdAt; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
public function getCreatedTime(): \DateTime |
|
263
|
|
|
{ |
|
264
|
|
|
return $this->createdTime; |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
public function getUpdatedTime(): \DateTime |
|
268
|
|
|
{ |
|
269
|
|
|
return $this->updatedTime; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
} |