作者 karlet

feat:okx k线对应

... ... @@ -349,7 +349,25 @@ class CmBroker
return $period;
}
if ($platTarget == self::PLAT_OKX) {
return str_replace('s', 'S', $period);
$arr = [
'1s' => 'candle1s',
'1m' => 'candle1m',
'3m' => 'candle3m',
'5m' => 'candle5m',
'15m' => 'candle15m',
'30m' => 'candle30m',
'1h' => 'candle1H',
'2h' => 'candle2H',
'4h' => 'candle4H',
'6h' => 'candle6H',
'12h' => 'candle12H',
'1d' => 'candle1D',
'1w' => 'candle1W',
];
if (!isset($arr[$period])) {
throw new Exception('周期错误,' . $this->plat . '不支持的周期' . $period);
}
return $arr[$period];
}
if ($platTarget == self::PLAT_BYBIT) {
$arr = [
... ...
... ... @@ -73,7 +73,7 @@ class ExBroker
$subData['op'] = 'subscribe';
$subData['args'] = [
[
'channel' => $this->getKlineChannels()[$period],
'channel' => $period,
'instId' => $symbol,
],
];
... ... @@ -178,22 +178,6 @@ class ExBroker
{
return $this->api->placeOrder($param);
}
public function getKlineChannels()
{
return [
'1s' => 'candle1s',
'1m' => 'candle1m',
'5m' => 'candle5m',
'15m' => 'candle15m',
'30m' => 'candle30m',
'1h' => 'candle1H',
'2h' => 'candle2H',
'4h' => 'candle4H',
'6h' => 'candle6H',
'12h' => 'candle12H',
'1d' => 'candle1D',
];
}
public function getSymbolInfos()
{
$res = $this->api->instruments(["instType" => "SWAP"]);
... ...