1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Carpenstar\ByBitAPI\WebSockets\Spot\PublicChannels\Tickers\Entities; |
4
|
|
|
|
5
|
|
|
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper; |
6
|
|
|
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* https://bybit-exchange.github.io/docs/derivatives/ws-public/ticker |
10
|
|
|
*/ |
11
|
|
|
class TickersResponseItem extends AbstractResponse |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Trading pair |
15
|
|
|
* @var string $symbol |
16
|
|
|
*/ |
17
|
|
|
private string $symbol; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Timestamp (trading time in the match box) |
21
|
|
|
* @var null|\DateTime $timestamp |
22
|
|
|
*/ |
23
|
|
|
private ?\DateTime $timestamp; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Open price |
27
|
|
|
* @var float $openPrice |
28
|
|
|
*/ |
29
|
|
|
private float $openPrice; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* High price |
33
|
|
|
* @var float $highPrice |
34
|
|
|
*/ |
35
|
|
|
private float $highPrice; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Low price |
39
|
|
|
* @var float $lowPrice |
40
|
|
|
*/ |
41
|
|
|
private float $lowPrice; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Close price |
45
|
|
|
* @var float $closePrice |
46
|
|
|
*/ |
47
|
|
|
private float $closePrice; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Trading volume |
51
|
|
|
* @var float $tradingVolume |
52
|
|
|
*/ |
53
|
|
|
private float $tradingVolume; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Trading quote volume |
57
|
|
|
* @var float $tradinguoteVolume |
58
|
|
|
*/ |
59
|
|
|
private float $tradinqQuoteVolume; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Change |
63
|
|
|
* @var float $change |
64
|
|
|
*/ |
65
|
|
|
private float $change; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* USD index price. It can be empty |
69
|
|
|
* @var null|string $usdIndexPrice |
70
|
|
|
*/ |
71
|
|
|
private ?string $usdIndexPrice; |
72
|
|
|
|
73
|
|
|
public function __construct(array $data) |
74
|
|
|
{ |
75
|
|
|
$this->timestamp = DateTimeHelper::makeFromTimestamp($data['t']); |
76
|
|
|
$this->symbol = $data['s']; |
77
|
|
|
$this->openPrice = $data['o']; |
78
|
|
|
$this->highPrice = $data['h']; |
79
|
|
|
$this->lowPrice = $data['l']; |
80
|
|
|
$this->closePrice = $data['c']; |
81
|
|
|
$this->tradingVolume = $data['v']; |
82
|
|
|
$this->tradinqQuoteVolume = $data['qv']; |
83
|
|
|
$this->change = $data['m']; |
84
|
|
|
$this->usdIndexPrice = $data['xp']; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string|null |
89
|
|
|
*/ |
90
|
|
|
public function getSymbol(): ?string |
91
|
|
|
{ |
92
|
|
|
return $this->symbol; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return string|null |
97
|
|
|
*/ |
98
|
|
|
public function getOpenPrice(): ?float |
99
|
|
|
{ |
100
|
|
|
return $this->openPrice; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return float|null |
105
|
|
|
*/ |
106
|
|
|
public function getHighPrice(): ?float |
107
|
|
|
{ |
108
|
|
|
return $this->highPrice; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return float|null |
113
|
|
|
*/ |
114
|
|
|
public function getLowPrice(): ?float |
115
|
|
|
{ |
116
|
|
|
return $this->lowPrice; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return float|null |
121
|
|
|
*/ |
122
|
|
|
public function getClosePrice(): ?float |
123
|
|
|
{ |
124
|
|
|
return $this->closePrice; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return float|null |
129
|
|
|
*/ |
130
|
|
|
public function getTradingVolume(): ?float |
131
|
|
|
{ |
132
|
|
|
return $this->tradingVolume; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return float|null |
137
|
|
|
*/ |
138
|
|
|
public function getTradingQuoteVolume(): ?float |
139
|
|
|
{ |
140
|
|
|
return $this->tradinqQuoteVolume; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @return float|null |
145
|
|
|
*/ |
146
|
|
|
public function getChange(): ?float |
147
|
|
|
{ |
148
|
|
|
return $this->change; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return float|null |
153
|
|
|
*/ |
154
|
|
|
public function getUsdIndexPrice(): ?string |
155
|
|
|
{ |
156
|
|
|
return $this->usdIndexPrice; |
|
|
|
|
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return \DateTime|null |
161
|
|
|
*/ |
162
|
|
|
public function getTimestamp(): ?\DateTime |
163
|
|
|
{ |
164
|
|
|
return $this->timestamp; |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|