Test Failed
Push — master ( f1d563...1fab6c )
by Vladislav
10:20 queued 07:53
created

TickerInfoResponseItem::getOpenInterestValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Response;
3
4
5
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
6
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
7
use Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Interfaces\ITickerInfoResponseItemInterface;
8
9
10
class TickerInfoResponseItem extends AbstractResponse implements ITickerInfoResponseItemInterface
11
{
12
    /**
13
     * Symbol name
14
     * @var string $symbol
15
     */
16
    private string $symbol;
17
18
    /**
19
     * Best bid price
20
     * @var float $bidPrice
21
     */
22
    private float $bidPrice;
23
24
    /**
25
     * Best ask price
26
     * @var float $askPrice
27
     */
28
    private float $askPrice;
29
30
    /**
31
     * Last transaction price
32
     * @var float $lastPrice
33
     */
34
    private float $lastPrice;
35
36
    /**
37
     * Direction of price change
38
     * @var string $lastTickDirection
39
     */
40
    private string $lastTickDirection;
41
42
    /**
43
     * Price of 24 hours ago
44
     * @var float $prevPrice24h
45
     */
46
    private float $prevPrice24h;
47
48
    /**
49
     * Percentage change of market price relative to 24h
50
     * @var float $price24hPcnt
51
     */
52
    private float $price24hPcnt;
53
54
    /**
55
     * The highest price in the last 24 hours
56
     * @var float $highPrice24h
57
     */
58
    private float $highPrice24h;
59
60
    /**
61
     * Lowest price in the last 24 hours
62
     * @var float $lowPrice24h
63
     */
64
    private float $lowPrice24h;
65
66
    /**
67
     * Hourly market price an hour ago
68
     * @var float $prevPrice1h
69
     */
70
    private float $prevPrice1h;
71
72
    /**
73
     * Mark price
74
     * @var float $markPrice
75
     */
76
    private float $markPrice;
77
78
    /**
79
     * Index price
80
     * @var float $indexPrice
81
     */
82
    private float $indexPrice;
83
84
    /**
85
     * Open interest
86
     * @var float $openInterests
87
     */
88
    private ?float $openInterests;
89
90
    /**
91
     * Turnover in the last 24 hours
92
     * @var float $turnover24h
93
     */
94
    private float $turnover24h;
95
96
    /**
97
     * Trading volume in the last 24 hours
98
     * @var float $volume24h
99
     */
100
    private float $volume24h;
101
102
    /**
103
     * Funding rate
104
     * @var float $fundingRate
105
     */
106
    private float $fundingRate;
107
108
    /**
109
     * Next timestamp for funding to settle
110
     * @var \DateTime $nextFundingTime
111
     */
112
    private \DateTime $nextFundingTime;
113
114
    /**
115
     * Predicted delivery price. It has value when 30 min before delivery
116
     * @var float $predictedDeliveryPrice
117
     */
118
    private float $predictedDeliveryPrice;
119
120
    /**
121
     * Basis rate for futures
122
     * @var float $basisRate
123
     */
124
    private float $basisRate;
125
126
    /**
127
     * Delivery fee rate
128
     * @var float $deliveryFeeRate
129
     */
130
    private float $deliveryFeeRate;
131
132
    /**
133
     * Delivery timestamp (ms)
134
     * @var \DateTime $deliveryTime
135
     */
136
    private \DateTime $deliveryTime;
137
138
    /**
139
     * Open interest value
140
     * @var float $openInterestValue
141
     */
142
    private float $openInterestValue;
143
144
    public function __construct(array $data)
145
    {
146
        $this->symbol = $data['symbol'];
147
        $this->bidPrice = $data['bidPrice'];
148
        $this->askPrice = $data['askPrice'];
149
        $this->lastPrice = $data['lastPrice'];
150
        $this->lastTickDirection = $data['lastTickDirection'];
151
        $this->prevPrice24h = $data['prevPrice24h'];
152
        $this->price24hPcnt = $data['price24hPcnt'];
153
        $this->highPrice24h = $data['highPrice24h'];
154
        $this->lowPrice24h = $data['lowPrice24h'];
155
        $this->prevPrice1h = $data['prevPrice1h'];
156
        $this->markPrice = $data['markPrice'];
157
        $this->indexPrice = $data['indexPrice'];
158
        $this->openInterests = $data['openInterest'];
159
        $this->turnover24h = $data['turnover24h'];
160
        $this->volume24h = $data['volume24h'];
161
        $this->fundingRate = $data['fundingRate'];
162
        $this->nextFundingTime = DateTimeHelper::makeFromTimestamp((int) $data['nextFundingTime']);
163
        $this->predictedDeliveryPrice = (float)$data['predictedDeliveryPrice'];
164
        $this->basisRate = (float)$data['basisRate'];
165
        $this->deliveryFeeRate = (float)$data['deliveryFeeRate'];
166
        $this->deliveryTime = DateTimeHelper::makeFromTimestamp((int) $data['deliveryTime']);
167
        $this->openInterestValue = $data['openInterestValue'];
168
    }
169
170
    /**
171
     * @return string
172
     */
173
    public function getSymbol(): string
174
    {
175
        return $this->symbol;
176
    }
177
178
    /**
179
     * @return float
180
     */
181
    public function getBidPrice(): float
182
    {
183
        return $this->bidPrice;
184
    }
185
186
    /**
187
     * @return float
188
     */
189
    public function getAskPrice(): float
190
    {
191
        return $this->askPrice;
192
    }
193
194
    /**
195
     * @return float
196
     */
197
    public function getLastPrice(): float
198
    {
199
        return $this->lastPrice;
200
    }
201
202
    /**
203
     * @return string
204
     */
205
    public function getLastTickDirection(): string
206
    {
207
        return $this->lastTickDirection;
208
    }
209
210
    /**
211
     * @return float
212
     */
213
    public function getPrevPrice24h(): float
214
    {
215
        return $this->prevPrice24h;
216
    }
217
218
    /**
219
     * @return float
220
     */
221
    public function getPrice24hPcnt(): float
222
    {
223
        return $this->price24hPcnt;
224
    }
225
226
    /**
227
     * @return float
228
     */
229
    public function getHighPrice24h(): float
230
    {
231
        return $this->highPrice24h;
232
    }
233
234
    /**
235
     * @return float
236
     */
237
    public function getLowPrice24h(): float
238
    {
239
        return $this->lowPrice24h;
240
    }
241
242
    /**
243
     * @return float
244
     */
245
    public function getPrevPrice1h(): float
246
    {
247
        return $this->prevPrice1h;
248
    }
249
250
    /**
251
     * @return float
252
     */
253
    public function getMarkPrice(): float
254
    {
255
        return $this->markPrice;
256
    }
257
258
    /**
259
     * @return float
260
     */
261
    public function getIndexPrice(): float
262
    {
263
        return $this->indexPrice;
264
    }
265
266
    /**
267
     * @return float
268
     */
269
    public function getOpenInterests(): float
270
    {
271
        return (float)$this->openInterests;
272
    }
273
274
    /**
275
     * @return float
276
     */
277
    public function getTurnover24h(): float
278
    {
279
        return $this->turnover24h;
280
    }
281
282
    /**
283
     * @return float
284
     */
285
    public function getVolume24h(): float
286
    {
287
        return $this->volume24h;
288
    }
289
290
    /**
291
     * @return float
292
     */
293
    public function getFundingRate(): float
294
    {
295
        return $this->fundingRate;
296
    }
297
298
    /**
299
     * @return \DateTime
300
     */
301
    public function getNextFundingTime(): \DateTime
302
    {
303
        return $this->nextFundingTime;
304
    }
305
306
    /**
307
     * @return float
308
     */
309
    public function getPredictedDeliveryPrice(): float
310
    {
311
        return $this->predictedDeliveryPrice;
312
    }
313
314
    /**
315
     * @return float
316
     */
317
    public function getBasisRate(): float
318
    {
319
        return $this->basisRate;
320
    }
321
322
    /**
323
     * @return float
324
     */
325
    public function getDeliveryFeeRate(): float
326
    {
327
        return $this->deliveryFeeRate;
328
    }
329
330
    /**
331
     * @return \DateTime
332
     */
333
    public function getDeliveryTime(): \DateTime
334
    {
335
        return $this->deliveryTime;
336
    }
337
338
    /**
339
     * @return float
340
     */
341
    public function getOpenInterestValue(): float
342
    {
343
        return $this->openInterestValue;
344
    }
345
}