IndexTicker.php
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace trader\struct;
class IndexTicker
{
public string $symbol = "";
public float $price = 0.0;
public float $high24 = 0.0;
public float $low24 = 0.0;
public float $open24 = 0.0;
public function __construct($symbol, $price, $high24, $low24, $open24)
{
$this->symbol = $symbol;
$this->price = $price;
$this->high24 = $high24;
$this->low24 = $low24;
$this->open24 = $open24;
}
public function toArray()
{
return [
'symbol' => $this->symbol,
'price' => $this->price,
'high24' => $this->high24,
'low24' => $this->low24,
'open24' => $this->open24,
];
}
public static function transferOkxData($data): array
{
$res = [];
foreach ($data as $item) {
$symbol = str_replace('-', '', $item['instId']);
$res[] = new IndexTicker($symbol, $item['idxPx'], $item['high24h'], $item['low24h'], $item['open24h']);
}
return $res;
}
}