作者 karlet

feat:持仓模式

... ... @@ -48,6 +48,8 @@ class CmBroker
const PLAT_BITGET = 'bitget';
const BN_FEE_KEY = "x-tdk3UjFd";
const OK_FEE_KEY = "059de09b75e8BCDE";
const MODE_TWO_SIDE = 'TWO_SIDE';
const MODE_ONE_SIDE = 'ONE_SIDE';
/**
* @var string 当前使用的交易平台
* @see PLAT_OKX
... ... @@ -64,6 +66,7 @@ class CmBroker
public $name = '';
public $levers = [];
public $uid;
public $posMode = '';
public function __construct($plat, ?ApiInfo $apiInfo, $wsHost = null, $restHost = null)
... ... @@ -101,6 +104,7 @@ class CmBroker
}
public function init()
{
$this->initPosMode();
$this->initSymbolInfos();
}
public function accListen(callable $onData)
... ... @@ -730,4 +734,12 @@ class CmBroker
}
return $data;
}
private function initPosMode()
{
if ($this->plat == self::PLAT_OKX) {
$res = $this->exBroker->getAccountConfig();
$config = $res['data'][0];
$this->posMode = $config['posMode'] == 'long_short_mode' ? self::MODE_TWO_SIDE : self::MODE_ONE_SIDE;
}
}
}
... ...
... ... @@ -114,6 +114,12 @@ class Api
$method = 'POST';
return $this->request($path, $method, $param, $this->apiInfo);
}
public function getAccountConfig($param = [])
{
$path = '/api/v5/account/config';
$method = 'GET';
return $this->request($path, $method, $param, $this->apiInfo);
}
//-------------------------------------
... ...
... ... @@ -383,4 +383,8 @@ class ExBroker
$res = $this->api->fundingRate($param);
return $res;
}
public function getAccountConfig()
{
return $this->api->getAccountConfig();
}
}
... ...