|
...
|
...
|
@@ -240,4 +240,50 @@ class ExBroker |
|
|
|
$res = $this->api->setPositionMode($param);
|
|
|
|
output("设置持仓模式", $res);
|
|
|
|
}
|
|
|
|
//获取所有品种杠杆信息
|
|
|
|
public function getAllLevers()
|
|
|
|
{
|
|
|
|
//获取所有USDT SWAP 交易对
|
|
|
|
$res = $this->api->instruments(["instType" => "SWAP"]);
|
|
|
|
$Symbols = [];
|
|
|
|
foreach ($res["data"] as $key => $value) {
|
|
|
|
if ($value["settleCcy"] == "USDT") {
|
|
|
|
$Symbols[] = $value["instId"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取所有品种的杠杆信息
|
|
|
|
return $this->getLevers($Symbols);
|
|
|
|
}
|
|
|
|
//获取杠杆
|
|
|
|
private function getLevers($symbols)
|
|
|
|
{
|
|
|
|
$levers = [];
|
|
|
|
$param = [
|
|
|
|
'mgnMode' => 'cross'
|
|
|
|
];
|
|
|
|
$count = 0;
|
|
|
|
$instId = '';
|
|
|
|
foreach ($symbols as $key => $value) {
|
|
|
|
$count++;
|
|
|
|
if ($instId == '') {
|
|
|
|
$instId = $value;
|
|
|
|
} else {
|
|
|
|
$instId = $instId . ',' . $value;
|
|
|
|
}
|
|
|
|
if ($count % 20 == 0 || $count == count($symbols)) {
|
|
|
|
$param['instId'] = $instId;
|
|
|
|
$instId = '';
|
|
|
|
$res = $this->api->leverageInfo($param, $this->apiInfo);
|
|
|
|
if ($res['code'] == 0) {
|
|
|
|
foreach ($res["data"] as $key => $value) {
|
|
|
|
$levers[$value["instId"]] = $value["lever"];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var_dump($res);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $levers;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|