|
@@ -240,4 +240,50 @@ class ExBroker |
|
@@ -240,4 +240,50 @@ class ExBroker |
|
240
|
$res = $this->api->setPositionMode($param);
|
240
|
$res = $this->api->setPositionMode($param);
|
|
241
|
output("设置持仓模式", $res);
|
241
|
output("设置持仓模式", $res);
|
|
242
|
}
|
242
|
}
|
|
|
|
243
|
+ //获取所有品种杠杆信息
|
|
|
|
244
|
+ public function getAllLevers()
|
|
|
|
245
|
+ {
|
|
|
|
246
|
+ //获取所有USDT SWAP 交易对
|
|
|
|
247
|
+ $res = $this->api->instruments(["instType" => "SWAP"]);
|
|
|
|
248
|
+ $Symbols = [];
|
|
|
|
249
|
+ foreach ($res["data"] as $key => $value) {
|
|
|
|
250
|
+ if ($value["settleCcy"] == "USDT") {
|
|
|
|
251
|
+ $Symbols[] = $value["instId"];
|
|
|
|
252
|
+ }
|
|
|
|
253
|
+ }
|
|
|
|
254
|
+ //获取所有品种的杠杆信息
|
|
|
|
255
|
+ return $this->getLevers($Symbols);
|
|
|
|
256
|
+ }
|
|
|
|
257
|
+ //获取杠杆
|
|
|
|
258
|
+ private function getLevers($symbols)
|
|
|
|
259
|
+ {
|
|
|
|
260
|
+ $levers = [];
|
|
|
|
261
|
+ $param = [
|
|
|
|
262
|
+ 'mgnMode' => 'cross'
|
|
|
|
263
|
+ ];
|
|
|
|
264
|
+ $count = 0;
|
|
|
|
265
|
+ $instId = '';
|
|
|
|
266
|
+ foreach ($symbols as $key => $value) {
|
|
|
|
267
|
+ $count++;
|
|
|
|
268
|
+ if ($instId == '') {
|
|
|
|
269
|
+ $instId = $value;
|
|
|
|
270
|
+ } else {
|
|
|
|
271
|
+ $instId = $instId . ',' . $value;
|
|
|
|
272
|
+ }
|
|
|
|
273
|
+ if ($count % 20 == 0 || $count == count($symbols)) {
|
|
|
|
274
|
+ $param['instId'] = $instId;
|
|
|
|
275
|
+ $instId = '';
|
|
|
|
276
|
+ $res = $this->api->leverageInfo($param, $this->apiInfo);
|
|
|
|
277
|
+ if ($res['code'] == 0) {
|
|
|
|
278
|
+ foreach ($res["data"] as $key => $value) {
|
|
|
|
279
|
+ $levers[$value["instId"]] = $value["lever"];
|
|
|
|
280
|
+ }
|
|
|
|
281
|
+ } else {
|
|
|
|
282
|
+ var_dump($res);
|
|
|
|
283
|
+ break;
|
|
|
|
284
|
+ }
|
|
|
|
285
|
+ }
|
|
|
|
286
|
+ }
|
|
|
|
287
|
+ return $levers;
|
|
|
|
288
|
+ }
|
|
243
|
} |
289
|
} |