fix(okx): 修复账户余额获取和API请求处理问题
- 修改账户余额查询逻辑,改为获取USDT合约账户余额
- 更新WebSocket连接地址为业务地址(wss://.../ws/v5/business)
- 添加pong消息处理避免心跳异常
- 修改条件单取消接口调用方式,使用原始请求体格式
- 新增sendSignedRequestRaw方法支持原始请求体签名
| | |
| | | params.put("posSide", posSide); |
| | | params.put("ordType", "conditional"); |
| | | params.put("sz", size); |
| | | params.put("triggerPx", triggerPrice); |
| | | params.put("triggerPxType", "last"); |
| | | params.put("orderPx", "-1"); // 市价成交 |
| | | params.put("slTriggerPx", triggerPrice); |
| | | params.put("slTriggerPxType", "last"); |
| | | params.put("slOrdPx", "-1"); |
| | | |
| | | String resp = okxAccount.requestHandler.sendSignedRequest( |
| | | okxAccount.baseUrl, "/api/v5/trade/order-algo", params, HttpMethod.POST, okxAccount.isSimluate()); |
| | |
| | | if (data == null || data.isEmpty()) return true; |
| | | for (int i = 0; i < data.size(); i++) { |
| | | JSONObject pos = data.getJSONObject(i); |
| | | if (!instId.equals(pos.getString("instId"))) continue; |
| | | String posInstId = pos.getString("instId"); |
| | | if (posInstId == null || !instId.equals(posInstId)) continue; |
| | | |
| | | String posSide = pos.getString("posSide"); |
| | | BigDecimal posSize = new BigDecimal(pos.getString("pos")); |
| | | BigDecimal avgPx = new BigDecimal(pos.getString("avgPx")); |
| | | String posStr = pos.getString("pos"); |
| | | String avgPxStr = pos.getString("avgPx"); |
| | | if (posStr == null || posStr.isEmpty() || avgPxStr == null || avgPxStr.isEmpty()) continue; |
| | | |
| | | BigDecimal posSize = new BigDecimal(posStr); |
| | | BigDecimal avgPx = new BigDecimal(avgPxStr); |
| | | log.info("[OKX-WS] 持仓更新, instId:{}, posSide:{}, pos:{}, avgPx:{}", |
| | | instId, posSide, posSize, avgPx); |
| | | |