作者 karlet

feat:增加币安获取全部杠杆

@@ -280,7 +280,7 @@ class CmBroker @@ -280,7 +280,7 @@ class CmBroker
280 public function getLevers() 280 public function getLevers()
281 { 281 {
282 $levers = $this->exBroker->getAllLevers(); 282 $levers = $this->exBroker->getAllLevers();
283 - if ($this->plat == self::PLAT_OKX) { 283 + if ($this->plat == self::PLAT_OKX || $this->plat == self::PLAT_BINANCE) {
284 $resNew = []; 284 $resNew = [];
285 foreach ($levers as $key => $value) { 285 foreach ($levers as $key => $value) {
286 $symbol = $this->getSymbolSt($key); //转换为标准交易对 286 $symbol = $this->getSymbolSt($key); //转换为标准交易对
@@ -46,6 +46,13 @@ class Api @@ -46,6 +46,13 @@ class Api
46 $method = "POST"; 46 $method = "POST";
47 return $this->request($method, $url, $params, $this->apiInfo); 47 return $this->request($method, $url, $params, $this->apiInfo);
48 } 48 }
  49 + //获取账户持仓风险v2
  50 + public function getPositionRiskV2($params)
  51 + {
  52 + $url = "/fapi/v2/positionRisk";
  53 + $method = "GET";
  54 + return $this->request($method, $url, $params, $this->apiInfo);
  55 + }
49 56
50 //------------------------------------ 57 //------------------------------------
51 58
@@ -96,4 +96,14 @@ class ExBroker @@ -96,4 +96,14 @@ class ExBroker
96 } 96 }
97 return $res; 97 return $res;
98 } 98 }
  99 + //获取所有账户杠杆
  100 + public function getAllLeverage()
  101 + {
  102 + $res = $this->api->getPositionRiskV2([]);
  103 + $retArr = [];
  104 + foreach ($res as $v) {
  105 + $retArr[$v['symbol']] = $v['leverage'];
  106 + }
  107 + return $retArr;
  108 + }
99 } 109 }