fix(okx): 修复账户余额获取和API请求处理问题
- 修改账户余额查询逻辑,改为获取USDT合约账户余额
- 更新WebSocket连接地址为业务地址(wss://.../ws/v5/business)
- 添加pong消息处理避免心跳异常
- 修改条件单取消接口调用方式,使用原始请求体格式
- 新增sendSignedRequestRaw方法支持原始请求体签名
| | |
| | | if ("0".equals(json.getString("code"))) { |
| | | JSONArray data = json.getJSONArray("data"); |
| | | if (data != null && !data.isEmpty()) { |
| | | JSONObject detail = data.getJSONObject(0); |
| | | String totalEq = detail.getString("totalEq"); |
| | | if (totalEq != null) { |
| | | this.initialPrincipal = new BigDecimal(totalEq); |
| | | JSONObject accountData = data.getJSONObject(0); |
| | | JSONArray details = accountData.getJSONArray("details"); |
| | | if (details != null) { |
| | | for (int i = 0; i < details.size(); i++) { |
| | | JSONObject detail = details.getJSONObject(i); |
| | | if ("USDT".equals(detail.getString("ccy"))) { |
| | | String eq = detail.getString("eq"); |
| | | if (eq != null) { |
| | | this.initialPrincipal = new BigDecimal(eq); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param onFailure 失败回调 |
| | | */ |
| | | public void openLong(String quantity, Consumer<String> onSuccess, Runnable onFailure) { |
| | | submitOrder("buy", "long", quantity, "market", null, false, "t-okx-grid-long", onSuccess, onFailure); |
| | | submitOrder("buy", "long", quantity, "market", null, false, "tGridLong", onSuccess, onFailure); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param onFailure 失败回调 |
| | | */ |
| | | public void openShort(String quantity, Consumer<String> onSuccess, Runnable onFailure) { |
| | | submitOrder("sell", "short", quantity, "market", null, false, "t-okx-grid-short", onSuccess, onFailure); |
| | | submitOrder("sell", "short", quantity, "market", null, false, "tGridShort", onSuccess, onFailure); |
| | | } |
| | | |
| | | /** |