From cdfc565cf68600e4690f6668b9a08889a81ca6af Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 11 Dec 2025 20:48:56 +0800
Subject: [PATCH] feat(okx): 增强OKX WebSocket连接稳定性
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
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 f7ffced..f76d187 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
@@ -14,6 +14,8 @@
import java.math.BigDecimal;
/**
+ * 交易订单处理类,负责构建和发送订单请求到OKX WebSocket
+ *
* @author Administrator
*/
@Slf4j
@@ -24,18 +26,28 @@
public static void orderEvent(WebSocketClient webSocketClient, RedisUtils redisUtils, String side) {
log.info("开始执行TradeOrderWs......");
+ if (StrUtil.isBlank( side)){
+ log.warn("止损了,下次再战...");
+ return;
+ }
+ String live = (String) redisUtils.getWithDelay(ORDERWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state");
+ if (!CoinEnums.ORDER_LIVE.getCode().equals( live)){
+ log.warn("正在下单中,等待下单结束...");
+ return;
+ }
String buyCnt = null;
String ctval = getRedisValue(redisUtils, InstrumentsWs.INSTRUMENTSWS_CHANNEL, ":ctVal");
String buyCntNormal = getRedisValue(redisUtils, PositionsWs.POSITIONSWS_CHANNEL, ":buyCnt");
String pos = getRedisValue(redisUtils, PositionsWs.POSITIONSWS_CHANNEL, ":pos");
if (OrderParamEnums.ORDERING.getValue().equals(side)) {
+ log.warn("正在下单中,等待下单结束...");
return;
} else if (OrderParamEnums.HOLDING.getValue().equals(side)) {
return;
} else if (OrderParamEnums.INIT.getValue().equals(side)) {
side = OrderParamEnums.BUY.getValue();
- if (StrUtil.isNotBlank(buyCntNormal) && BigDecimal.ZERO.compareTo(new BigDecimal(buyCntNormal)) > 0) {
+ if (StrUtil.isNotBlank(buyCntNormal) && new BigDecimal(buyCntNormal).compareTo(BigDecimal.ZERO) > 0) {
buyCnt = buyCntNormal;
}else{
buyCnt = ctval;
@@ -46,7 +58,7 @@
buyCnt = pos;
} else if (OrderParamEnums.BUY.getValue().equals(side)){
side = OrderParamEnums.BUY.getValue();
- if (StrUtil.isNotBlank(buyCntNormal) && BigDecimal.ZERO.compareTo(new BigDecimal(buyCntNormal)) > 0) {
+ if (StrUtil.isNotBlank(buyCntNormal) && new BigDecimal(buyCntNormal).compareTo(BigDecimal.ZERO) > 0) {
buyCnt = buyCntNormal;
}else{
buyCnt = ctval;
@@ -140,4 +152,4 @@
Object valueObj = redisUtils.get(key);
return valueObj == null ? null : String.valueOf(valueObj);
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.1