作者 karlet

feat:增加双向合约设置

... ... @@ -226,4 +226,14 @@ class CmBroker
{
$this->exBroker->closeAllPos();
}
//设置允许合约
public function setAllowFutures($isAllowFutures)
{
$this->exBroker->setAllowFutures($isAllowFutures);
}
//设置双向持仓模式
public function setLongShortMode($isLongShort)
{
$this->exBroker->setLongShortMode($isLongShort);
}
}
... ...
... ... @@ -91,7 +91,21 @@ class Api
{
$path = '/api/v5/account/positions';
$method = 'GET';
return self::request($path, $method, $param, $this->apiInfo);
return $this->request($path, $method, $param, $this->apiInfo);
}
//设置账户模式
public function setAccountLevel($param)
{
$path = '/api/v5/account/set-account-level';
$method = 'POST';
return $this->request($path, $method, $param, $this->apiInfo);
}
//设置持仓模式
public function setPositionMode($param)
{
$path = '/api/v5/account/set-position-mode';
$method = 'POST';
return $this->request($path, $method, $param, $this->apiInfo);
}
//-------------------------------------
... ...
... ... @@ -222,4 +222,22 @@ class ExBroker
return false;
}
}
// 设置是否允许合约
public function setAllowFutures($isAllowFutures)
{
$param = [
'acctLv' => $isAllowFutures ? '2' : '1',
];
$res = $this->api->setAccountLevel($param);
output("设置合约模式", $res);
}
// 设置为双向持仓
public function setLongShortMode($isLongShort)
{
$param = [
'posMode' => $isLongShort ? 'long_short_mode' : 'net_mode',
];
$res = $this->api->setPositionMode($param);
output("设置持仓模式", $res);
}
}
... ...