正在显示
3 个修改的文件
包含
43 行增加
和
1 行删除
| @@ -226,4 +226,14 @@ class CmBroker | @@ -226,4 +226,14 @@ class CmBroker | ||
| 226 | { | 226 | { |
| 227 | $this->exBroker->closeAllPos(); | 227 | $this->exBroker->closeAllPos(); |
| 228 | } | 228 | } |
| 229 | + //设置允许合约 | ||
| 230 | + public function setAllowFutures($isAllowFutures) | ||
| 231 | + { | ||
| 232 | + $this->exBroker->setAllowFutures($isAllowFutures); | ||
| 233 | + } | ||
| 234 | + //设置双向持仓模式 | ||
| 235 | + public function setLongShortMode($isLongShort) | ||
| 236 | + { | ||
| 237 | + $this->exBroker->setLongShortMode($isLongShort); | ||
| 238 | + } | ||
| 229 | } | 239 | } |
| @@ -91,7 +91,21 @@ class Api | @@ -91,7 +91,21 @@ class Api | ||
| 91 | { | 91 | { |
| 92 | $path = '/api/v5/account/positions'; | 92 | $path = '/api/v5/account/positions'; |
| 93 | $method = 'GET'; | 93 | $method = 'GET'; |
| 94 | - return self::request($path, $method, $param, $this->apiInfo); | 94 | + return $this->request($path, $method, $param, $this->apiInfo); |
| 95 | + } | ||
| 96 | + //设置账户模式 | ||
| 97 | + public function setAccountLevel($param) | ||
| 98 | + { | ||
| 99 | + $path = '/api/v5/account/set-account-level'; | ||
| 100 | + $method = 'POST'; | ||
| 101 | + return $this->request($path, $method, $param, $this->apiInfo); | ||
| 102 | + } | ||
| 103 | + //设置持仓模式 | ||
| 104 | + public function setPositionMode($param) | ||
| 105 | + { | ||
| 106 | + $path = '/api/v5/account/set-position-mode'; | ||
| 107 | + $method = 'POST'; | ||
| 108 | + return $this->request($path, $method, $param, $this->apiInfo); | ||
| 95 | } | 109 | } |
| 96 | 110 | ||
| 97 | //------------------------------------- | 111 | //------------------------------------- |
| @@ -222,4 +222,22 @@ class ExBroker | @@ -222,4 +222,22 @@ class ExBroker | ||
| 222 | return false; | 222 | return false; |
| 223 | } | 223 | } |
| 224 | } | 224 | } |
| 225 | + // 设置是否允许合约 | ||
| 226 | + public function setAllowFutures($isAllowFutures) | ||
| 227 | + { | ||
| 228 | + $param = [ | ||
| 229 | + 'acctLv' => $isAllowFutures ? '2' : '1', | ||
| 230 | + ]; | ||
| 231 | + $res = $this->api->setAccountLevel($param); | ||
| 232 | + output("设置合约模式", $res); | ||
| 233 | + } | ||
| 234 | + // 设置为双向持仓 | ||
| 235 | + public function setLongShortMode($isLongShort) | ||
| 236 | + { | ||
| 237 | + $param = [ | ||
| 238 | + 'posMode' => $isLongShort ? 'long_short_mode' : 'net_mode', | ||
| 239 | + ]; | ||
| 240 | + $res = $this->api->setPositionMode($param); | ||
| 241 | + output("设置持仓模式", $res); | ||
| 242 | + } | ||
| 225 | } | 243 | } |
-
请 注册 或 登录 后发表评论