Administrator
2025-12-17 603d1642239c1f550c44c1c78e19f524f7186122
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/PositionsWs.java
@@ -41,7 +41,7 @@
            String connId = MallUtils.getOrderNum(POSITIONSWS_CHANNEL);
            JSONObject jsonObject = WsParamBuild.buildJsonObject(connId, option, argsArray);
            webSocketClient.send(jsonObject.toJSONString());
//            log.info("发送持仓频道频道:{}", option);
            log.info("发送持仓频道频道:{}", option);
        } catch (Exception e) {
            log.error("订阅持仓频道频道构建失败", e);
        }
@@ -52,7 +52,7 @@
    }
    public static void initEvent(JSONObject response, String accountName) {
//        log.info("订阅成功,数据初始化: {}", response.getJSONObject("arg"));
        log.info("订阅成功,数据初始化: {}", response.getJSONObject("arg"));
        JSONObject arg = response.getJSONObject("arg");
        initParam(arg, accountName,CoinEnums.POSSIDE_LONG.getCode());
        initParam(arg, accountName,CoinEnums.POSSIDE_SHORT.getCode());
@@ -61,14 +61,11 @@
    public static void handleEvent(JSONObject response, String accountName) {
//        log.info("开始执行PositionsWs......");
        log.info("开始执行PositionsWs......");
        try {
            JSONArray dataArray = response.getJSONArray("data");
            if (dataArray == null || dataArray.isEmpty()) {
//                log.info("账户持仓频道数据为空,已当前价买入,并且初始化网格");
                JSONObject posData = new JSONObject();
                initParam(posData, accountName,CoinEnums.POSSIDE_LONG.getCode());
                initParam(posData, accountName,CoinEnums.POSSIDE_SHORT.getCode());
                log.info("账户持仓频道数据为空,等待更新");
                return;
            }
@@ -76,7 +73,7 @@
                JSONObject posData = dataArray.getJSONObject(i);
                String instId = posData.getString("instId");
                if (CoinEnums.HE_YUE.getCode().equals(instId)) {
//                    log.info("查询到账户{}持仓数据",CoinEnums.HE_YUE.getCode());
                    log.info("查询到账户{}持仓数据",CoinEnums.HE_YUE.getCode());
                    String mgnMode = posData.getString("mgnMode");
                    String posSide = posData.getString("posSide");
                    String pos = posData.getString("pos");
@@ -104,13 +101,17 @@
                                    + "维持保证金率: {}, 维持保证金: {}, 以美金价值为单位的持仓数量: {}, 占用保证金的币种: {}, "
                                    + "最新成交价: {}, 最新指数价格: {}, 盈亏平衡价: {}, 已实现收益: {}, 累计已结算收益: {}"
                                    + "最新标记价格: {},累计手续费: {},累计持仓费: {},",
                            accountName, instId, mgnMode, posSide, pos, avgPx,
                            initAccountName(accountName, posSide), instId, mgnMode, posSide, pos, avgPx,
                            upl, uplRatio, lever, liqPx, imr,
                            mgnRatio, mmr, notionalUsd, ccy,
                            last, idxPx, bePx, realizedPnl, settledPnl,
                            markPx,fee,fundingFee
                    );
                    initParam(posData, accountName,posSide);
                    String accountNamePositons = initAccountName(accountName, posSide);
                    Map<String, BigDecimal> accountMap = getAccountMap(accountNamePositons);
                    WsMapBuild.saveBigDecimalToMap(accountMap, CoinEnums.READY_STATE.name(), WsMapBuild.parseBigDecimalSafe(CoinEnums.READY_STATE_YES.getCode()));
                }
            }
        } catch (Exception e) {
@@ -131,7 +132,5 @@
        WsMapBuild.saveBigDecimalToMap(accountMap, "realizedPnl", WsMapBuild.parseBigDecimalSafe(posData.getString("realizedPnl")));
        WsMapBuild.saveBigDecimalToMap(accountMap, "fee", WsMapBuild.parseBigDecimalSafe(posData.getString("fee")));
        WsMapBuild.saveBigDecimalToMap(accountMap, "fundingFee", WsMapBuild.parseBigDecimalSafe(posData.getString("fundingFee")));
        WsMapBuild.saveBigDecimalToMap(accountMap, CoinEnums.READY_STATE.name(), WsMapBuild.parseBigDecimalSafe(CoinEnums.READY_STATE_YES.getCode()));
    }
}