作者 karlet

feat:查询获取所有仓位

... ... @@ -256,4 +256,17 @@ class CmBroker
$symbol = $this->getSymbolOri($symbol, $this->plat);
$this->exBroker->setLever($symbol, $lever);
}
//查询获取全部持仓
public function getAllPos(): array
{
$positions = $this->exBroker->getAllPos();
$newPositions = [];
foreach ($positions as $key => $value) {
$item = Pos::transferOkxPos($value, $this->symbolInfos, function ($symbol) {
return $this->getSymbolSt($symbol);
});
$newPositions[$item->symbol . "_" . $item->posSide] = $item;
}
return $newPositions;
}
}
... ...
... ... @@ -307,4 +307,24 @@ class ExBroker
return false;
}
}
//查询获取所有仓位
public function getAllPos()
{
$newPositions = [];
$param = [
'instType' => 'SWAP'
];
$res = $this->api->getPositions($param);
if ($res['code'] == 0) {
$positions = $res['data'];
foreach ($positions as $key => $value) {
if ($value['pos'] != 0) {
$newPositions[] = $value;
}
}
} else {
output($res);
}
return $newPositions;
}
}
... ...