Administrator
4 hours ago afc858458cbdde1d5f3f2cfce6d056656bf75c16
src/main/java/com/xcong/excoin/modules/okxApi/OkxRestClient.java
@@ -44,7 +44,24 @@
        return isSuccess(result, "设置杠杆");
    }
    public String fetchInstIdCode(String instType, String instId) {
    public boolean cancelAllOrders(String instId) {
        JSONObject params = new JSONObject();
        params.put("instType", "SWAP");
        params.put("instId", instId);
        JSONObject result = post("/api/v5/trade/cancel-all-orders", params);
        return isSuccess(result, "撤销所有委托单");
    }
    public boolean closeAllPositions(String instId, String mgnMode) {
        JSONObject params = new JSONObject();
        params.put("instType", "SWAP");
        params.put("instId", instId);
        params.put("mgnMode", mgnMode);
        JSONObject result = post("/api/v5/trade/close-all-positions", params);
        return isSuccess(result, "平仓ETH");
    }
    public Long fetchInstIdCode(String instType, String instId) {
        String path = "/api/v5/account/instruments?instType=" + instType + "&instId=" + instId;
        JSONObject result = get(path);
        if (result == null || !"0".equals(result.getString("code"))) {
@@ -59,7 +76,7 @@
            return null;
        }
        JSONObject first = data.getJSONObject(0);
        String instIdCode = first.getString("instIdCode");
        Long instIdCode = first.getLong("instIdCode");
        log.info("[REST] 获取instIdCode成功, instId:{}, instIdCode:{}", instId, instIdCode);
        return instIdCode;
    }
@@ -86,7 +103,9 @@
            int code = conn.getResponseCode();
            String response = readResponse(conn);
            log.info("[REST] GET {} → HTTP {} body:{}", path, code, response);
            if (code < 200 || code >= 300) {
                log.error("[REST] GET {} → HTTP {} body:{}", path, code, response);
            }
            return JSON.parseObject(response);
        } catch (Exception e) {
@@ -128,7 +147,9 @@
            int code = conn.getResponseCode();
            String response = readResponse(conn);
            log.info("[REST] POST {} → HTTP {} body:{}", path, code, response);
            if (code < 200 || code >= 300) {
                log.error("[REST] POST {} → HTTP {} body:{}", path, code, response);
            }
            return JSON.parseObject(response);
        } catch (Exception e) {