Administrator
2025-12-12 075ea812f48ab8e047eca83920dfe3291b471c0f
fix(okxNewPrice): 修复持仓数量判断逻辑

- 修改持仓数量获取键值从"imr"为"pos"
- 调整持仓数量为零时的初始化订单逻辑
- 在交易订单成交后更新持仓数量为零
2 files modified
16 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java 11 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java
@@ -105,17 +105,18 @@
            }
        }
        if (PositionsWs.POSITIONSWSMAP.get("imr") == null){
            log.error("没有获取到持仓信息,等待初始化......");
        if (PositionsWs.POSITIONSWSMAP.get("pos") == null){
            log.error("没有获取到持仓数量,等待初始化......");
            return null;
        }
        BigDecimal ordFrozImr = PositionsWs.POSITIONSWSMAP.get("imr");
        if (BigDecimal.ZERO.compareTo( ordFrozImr) >= 0) {
            log.error("占用保证金为零,进行初始化订单");
        BigDecimal pos = PositionsWs.POSITIONSWSMAP.get("pos");
        if (BigDecimal.ZERO.compareTo( pos) >= 0) {
            log.error("持仓数量为零,进行初始化订单");
            WsMapBuild.saveStringToMap(InstrumentsWs.INSTRUMENTSWSMAP, CoinEnums.STATE.name(), OrderParamEnums.STATE_4.getValue());
            return OrderParamEnums.INIT.getValue();
        }
        // 判断是否保证金超标
        BigDecimal ordFrozImr = PositionsWs.POSITIONSWSMAP.get("imr");
        BigDecimal totalOrderUsdt = WsMapBuild.parseBigDecimalSafe(AccountWs.ACCOUNTWSMAP.get(CoinEnums.TOTAL_ORDER_USDT.name()));
        if (ordFrozImr.compareTo(totalOrderUsdt) >= 0){
            log.error("已满仓......");
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java
@@ -83,6 +83,11 @@
            WsMapBuild.saveStringToMap(TRADEORDERWSMAP, "clOrdId", clOrdId);
            WsMapBuild.saveStringToMap(TRADEORDERWSMAP, "state", CoinEnums.ORDER_FILLED.getCode());
            if (OrderParamEnums.SELL.getValue().equals(side)){
                WsMapBuild.saveBigDecimalToMap(PositionsWs.POSITIONSWSMAP, "pos", BigDecimal.ZERO);
            }
        } catch (Exception e) {
            log.error("下单构建失败", e);
        }