Passed
Push — master ( f32712...07732c )
by Vladislav
04:33 queued 01:39
created

GetClosedPnLResponse::setClosedSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Response;
3
4
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
5
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
6
use Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Interfaces\IGetClosedPnLResponseInterface;
7
8
class GetClosedPnLResponse extends AbstractResponse implements IGetClosedPnLResponseInterface
9
{
10
    /**
11
     * Symbol name
12
     * @var string $symbol
13
     */
14
    private string $symbol;
15
16
    /**
17
     * Order Id
18
     * @var string $orderId
19
     */
20
    private string $orderId;
21
22
    /**
23
     * Sell, Buy, Side
24
     * @var string $side
25
     */
26
    private string $side;
27
28
    /**
29
     * Order qty
30
     * @var float $qty
31
     */
32
    private float $qty;
33
34
    /**
35
     * leverage
36
     * @var float $leverage
37
     */
38
    private float $leverage;
39
40
    /**
41
     * Order price
42
     * @var float $orderPrice
43
     */
44
    private float $orderPrice;
45
46
    /**
47
     * Order type. Market,Limit
48
     * @var string $orderType
49
     */
50
    private string $orderType;
51
52
    /**
53
     * Exec type
54
     * @var string $execType
55
     */
56
    private string $execType;
57
58
    /**
59
     * Closed size
60
     * @var float $closedSize
61
     */
62
    private float $closedSize;
63
64
    /**
65
     * Cumulated entry position value
66
     * @var float $cumEntryValue
67
     */
68
    private float $cumEntryValue;
69
70
    /**
71
     * Average entry price
72
     * @var float $avgEntryPrice
73
     */
74
    private float $avgEntryPrice;
75
76
    /**
77
     * Cumulated exit position value
78
     * @var float $cumExitValue
79
     */
80
    private float $cumExitValue;
81
82
    /**
83
     * Average exit price
84
     * @var float $avgExitPrice
85
     */
86
    private float $avgExitPrice;
87
88
    /**
89
     * Closed PnL
90
     * @var float $closedPnl
91
     */
92
    private float $closedPnl;
93
94
    /**
95
     * The number of fills in a single order
96
     * @var int $fillCount
97
     */
98
    private int $fillCount;
99
100
    /**
101
     * The created time (ms)
102
     * @var \DateTime $createdAt
103
     */
104
    private \DateTime $createdAt;
105
106
    public function __construct(array $data)
107
    {
108
        $this
109
            ->setSymbol($data['symbol'])
110
            ->setOrderId($data['orderId'])
111
            ->setSide($data['side'])
112
            ->setQty($data['qty'])
113
            ->setLeverage($data['leverage'])
114
            ->setOrderPrice($data['orderPrice'])
115
            ->setOrderType($data['orderType'])
116
            ->setExecType($data['execType'])
117
            ->setClosedSize($data['closedSize'])
118
            ->setCumEntryValue($data['cumEntryValue'])
119
            ->setAvgEntryPrice($data['avgEntryPrice'])
120
            ->setCumExitValue($data['cumExitValue'])
121
            ->setAvgExitPrice($data['avgExitPrice'])
122
            ->setClosedPnl($data['closedPnl'])
123
            ->setFillCount($data['fillCount'])
124
            ->setCreatedAt($data['createdAt']);
125
    }
126
127
    /**
128
     * @return string
129
     */
130
    public function getSymbol(): string
131
    {
132
        return $this->symbol;
133
    }
134
135
    /**
136
     * @param string $symbol
137
     * @return GetClosedPnLResponse
138
     */
139
    private function setSymbol(string $symbol): self
140
    {
141
        $this->symbol = $symbol;
142
        return $this;
143
    }
144
145
    /**
146
     * @return string
147
     */
148
    public function getOrderId(): string
149
    {
150
        return $this->orderId;
151
    }
152
153
    /**
154
     * @param string $orderId
155
     * @return GetClosedPnLResponse
156
     */
157
    private function setOrderId(string $orderId): self
158
    {
159
        $this->orderId = $orderId;
160
        return $this;
161
    }
162
163
    /**
164
     * @return string
165
     */
166
    public function getSide(): string
167
    {
168
        return $this->side;
169
    }
170
171
    /**
172
     * @param string $side
173
     * @return GetClosedPnLResponse
174
     */
175
    private function setSide(string $side): self
176
    {
177
        $this->side = $side;
178
        return $this;
179
    }
180
181
    /**
182
     * @return float
183
     */
184
    public function getQty(): float
185
    {
186
        return $this->qty;
187
    }
188
189
    /**
190
     * @param float $qty
191
     * @return GetClosedPnLResponse
192
     */
193
    private function setQty(float $qty): self
194
    {
195
        $this->qty = $qty;
196
        return $this;
197
    }
198
199
    /**
200
     * @return float
201
     */
202
    public function getLeverage(): float
203
    {
204
        return $this->leverage;
205
    }
206
207
    /**
208
     * @param float $leverage
209
     * @return GetClosedPnLResponse
210
     */
211
    private function setLeverage(float $leverage): self
212
    {
213
        $this->leverage = $leverage;
214
        return $this;
215
    }
216
217
    /**
218
     * @return float
219
     */
220
    public function getOrderPrice(): float
221
    {
222
        return $this->orderPrice;
223
    }
224
225
    /**
226
     * @param float $orderPrice
227
     * @return GetClosedPnLResponse
228
     */
229
    private function setOrderPrice(float $orderPrice): self
230
    {
231
        $this->orderPrice = $orderPrice;
232
        return $this;
233
    }
234
235
    /**
236
     * @return string
237
     */
238
    public function getOrderType(): string
239
    {
240
        return $this->orderType;
241
    }
242
243
    /**
244
     * @param string $orderType
245
     * @return GetClosedPnLResponse
246
     */
247
    private function setOrderType(string $orderType): self
248
    {
249
        $this->orderType = $orderType;
250
        return $this;
251
    }
252
253
    /**
254
     * @return string
255
     */
256
    public function getExecType(): string
257
    {
258
        return $this->execType;
259
    }
260
261
    /**
262
     * @param string $execType
263
     * @return GetClosedPnLResponse
264
     */
265
    private function setExecType(string $execType): self
266
    {
267
        $this->execType = $execType;
268
        return $this;
269
    }
270
271
    /**
272
     * @return float
273
     */
274
    public function getClosedSize(): float
275
    {
276
        return $this->closedSize;
277
    }
278
279
    /**
280
     * @param float $closedSize
281
     * @return GetClosedPnLResponse
282
     */
283
    private function setClosedSize(float $closedSize): self
284
    {
285
        $this->closedSize = $closedSize;
286
        return $this;
287
    }
288
289
    /**
290
     * @return float
291
     */
292
    public function getCumEntryValue(): float
293
    {
294
        return $this->cumEntryValue;
295
    }
296
297
    /**
298
     * @param float $cumEntryValue
299
     * @return GetClosedPnLResponse
300
     */
301
    private function setCumEntryValue(float $cumEntryValue): self
302
    {
303
        $this->cumEntryValue = $cumEntryValue;
304
        return $this;
305
    }
306
307
    /**
308
     * @return float
309
     */
310
    public function getAvgEntryPrice(): float
311
    {
312
        return $this->avgEntryPrice;
313
    }
314
315
    /**
316
     * @param float $avgEntryPrice
317
     * @return GetClosedPnLResponse
318
     */
319
    private function setAvgEntryPrice(float $avgEntryPrice): self
320
    {
321
        $this->avgEntryPrice = $avgEntryPrice;
322
        return $this;
323
    }
324
325
    /**
326
     * @return float
327
     */
328
    public function getCumExitValue(): float
329
    {
330
        return $this->cumExitValue;
331
    }
332
333
    /**
334
     * @param float $cumExitValue
335
     * @return GetClosedPnLResponse
336
     */
337
    private function setCumExitValue(float $cumExitValue): self
338
    {
339
        $this->cumExitValue = $cumExitValue;
340
        return $this;
341
    }
342
343
    /**
344
     * @return float
345
     */
346
    public function getAvgExitPrice(): float
347
    {
348
        return $this->avgExitPrice;
349
    }
350
351
    /**
352
     * @param float $avgExitPrice
353
     * @return GetClosedPnLResponse
354
     */
355
    private function setAvgExitPrice(float $avgExitPrice): self
356
    {
357
        $this->avgExitPrice = $avgExitPrice;
358
        return $this;
359
    }
360
361
    /**
362
     * @return float
363
     */
364
    public function getClosedPnl(): float
365
    {
366
        return $this->closedPnl;
367
    }
368
369
    /**
370
     * @param float $closedPnl
371
     * @return GetClosedPnLResponse
372
     */
373
    private function setClosedPnl(float $closedPnl): self
374
    {
375
        $this->closedPnl = $closedPnl;
376
        return $this;
377
    }
378
379
    /**
380
     * @return int
381
     */
382
    public function getFillCount(): int
383
    {
384
        return $this->fillCount;
385
    }
386
387
    /**
388
     * @param int $fillCount
389
     * @return GetClosedPnLResponse
390
     */
391
    private function setFillCount(int $fillCount): self
392
    {
393
        $this->fillCount = $fillCount;
394
        return $this;
395
    }
396
397
    /**
398
     * @return \DateTime
399
     */
400
    public function getCreatedAt(): \DateTime
401
    {
402
        return $this->createdAt;
403
    }
404
405
    /**
406
     * @param string $createdAt
407
     * @return GetClosedPnLResponse
408
     */
409
    private function setCreatedAt(string $createdAt): self
410
    {
411
        $this->createdAt = DateTimeHelper::makeFromTimestamp($createdAt);
0 ignored issues
show
Bug introduced by
$createdAt of type string is incompatible with the type integer expected by parameter $timestamp of Carpenstar\ByBitAPI\Core...er::makeFromTimestamp(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

411
        $this->createdAt = DateTimeHelper::makeFromTimestamp(/** @scrutinizer ignore-type */ $createdAt);
Loading history...
412
        return $this;
413
    }
414
415
416
}