Kline.php 1.1 KB
<?php

namespace trader\struct;

class Kline
{
    public $time;
    public $open;
    public $high;
    public $low;
    public $close;
    public $vol;
    public $volQuote;

    public function __construct($time, $open, $high, $low, $close, $vol, $volQuote)
    {
        $this->time = $time;
        $this->open = $open;
        $this->high = $high;
        $this->low = $low;
        $this->close = $close;
        $this->vol = $vol;
        $this->volQuote = $volQuote;
    }
    public function toArray()
    {
        return [
            'time' => $this->time,
            'open' => $this->open,
            'high' => $this->high,
            'low' => $this->low,
            'close' => $this->close,
            'vol' => $this->vol,
            'volQuote' => $this->volQuote,
        ];
    }
    public static function transferOkx($data)
    {
        $time = $data[0];
        $open = $data[1];
        $high = $data[2];
        $low = $data[3];
        $close = $data[4];
        $vol = $data[6];
        $volQuote = $data[7];
        return new Kline($time, $open, $high, $low, $close, $vol, $volQuote);
    }
}