From a80451b53728e62db65bafe7c4e7a43b5e3259cd Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 10 Dec 2025 14:11:20 +0800
Subject: [PATCH] feat(okxNewPrice): 新增止损冷静机制并优化订单状态控制
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java | 28 ++--------------------------
1 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
index 5aca7d2..96a483f 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
@@ -1,5 +1,6 @@
package com.xcong.excoin.modules.okxNewPrice;
+import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@@ -267,33 +268,8 @@
AccountWs.handleEvent(response, redisUtils);
} else if (PositionsWs.POSITIONSWS_CHANNEL.equals(channel)) {
PositionsWs.handleEvent(response, redisUtils);
-
- String posKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":pos";
- String pos = (String) redisUtils.get(posKey);
- if (StrUtil.isBlank(pos)) {
- log.error("未获取到持仓数量");
- TradeOrderWs.orderEvent(webSocketClient, redisUtils, OrderParamEnums.INIT.getValue());
- return;
- }
-
- String state = (String) redisUtils.get(InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state");
- String uplKey = PositionsWs.POSITIONSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":upl";
- String totalOrderUsdtKey = AccountWs.ACCOUNTWS_CHANNEL + ":" + CoinEnums.USDT.getCode() + ":totalOrderUsdt";
-
- String upl = (String) redisUtils.get(uplKey);
- String totalOrderUsdt = (String) redisUtils.get(totalOrderUsdtKey);
- BigDecimal multiply = new BigDecimal(upl).multiply(new BigDecimal("-1"));
-
- if (new BigDecimal(totalOrderUsdt).compareTo(multiply) < 0 || OrderParamEnums.STATE_3.getValue().equals(state)) {
- log.error("持仓盈亏超过下单总保证金,止损冷静一天......");
- TradeOrderWs.orderEvent(webSocketClient, redisUtils, OrderParamEnums.OUT.getValue());
- return;
- }
-
String side = caoZuoService.caoZuo();
- if (StrUtil.isNotBlank(pos)) {
- TradeOrderWs.orderEvent(webSocketClient, redisUtils, side);
- }
+ TradeOrderWs.orderEvent(webSocketClient, redisUtils, side);
} else if (BalanceAndPositionWs.CHANNEL_NAME.equals(channel)) {
BalanceAndPositionWs.handleEvent(response);
}
--
Gitblit v1.9.1