From 075ea812f48ab8e047eca83920dfe3291b471c0f Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Fri, 12 Dec 2025 14:12:57 +0800
Subject: [PATCH] fix(okxNewPrice): 修复持仓数量判断逻辑
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java | 11 ++++++-----
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java | 5 +++++
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java
index 8258f37..a85f4ae 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java
+++ b/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("已满仓......");
diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java
index 44d69dc..371cb17 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java
+++ b/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);
}
--
Gitblit v1.9.1