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