From a9402bbb84f6a521822fc8beb32056d0b2d4201f Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Fri, 26 Dec 2025 18:08:07 +0800
Subject: [PATCH] refactor(indicator): 重构MACD策略实现并优化交易逻辑
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 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 9a79fdc..22a0a0e 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
@@ -5,6 +5,7 @@
import com.xcong.excoin.modules.okxNewPrice.celue.CaoZuoService;
import com.xcong.excoin.modules.okxNewPrice.okxWs.*;
import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.ExchangeInfoEnum;
+import com.xcong.excoin.modules.okxNewPrice.okxWs.param.TradeRequestParam;
import com.xcong.excoin.modules.okxNewPrice.utils.SSLConfig;
import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeService;
import com.xcong.excoin.utils.RedisUtils;
@@ -31,8 +32,6 @@
*/
@Slf4j
public class OkxQuantWebSocketClient {
- private final WangGeService wangGeService;
- private final CaoZuoService caoZuoService;
private final RedisUtils redisUtils;
private final ExchangeInfoEnum account;
@@ -45,11 +44,25 @@
private final AtomicBoolean isConnected = new AtomicBoolean(false);
private final AtomicBoolean isConnecting = new AtomicBoolean(false);
- public OkxQuantWebSocketClient(ExchangeInfoEnum account, WangGeService wangGeService,
- CaoZuoService caoZuoService, RedisUtils redisUtils) {
+ /**
+ * 获取WebSocketClient实例
+ * @return WebSocketClient实例
+ */
+ public WebSocketClient getWebSocketClient() {
+ return webSocketClient;
+ }
+
+ /**
+ * 获取账号名称
+ * @return 账号名称
+ */
+ public String getAccountName() {
+ return account.name();
+ }
+
+ public OkxQuantWebSocketClient(ExchangeInfoEnum account,
+ RedisUtils redisUtils) {
this.account = account;
- this.wangGeService = wangGeService;
- this.caoZuoService = caoZuoService;
this.redisUtils = redisUtils;
}
@@ -174,7 +187,6 @@
try {
InstrumentsWs.handleEvent(account.name());
- wangGeService.initWangGe();
SSLConfig.configureSSL();
System.setProperty("https.protocols", "TLSv1.2,TLSv1.3");
String WS_URL = WS_URL_MONIPAN;
@@ -371,10 +383,10 @@
// 这会导致多账号之间的数据冲突。需要进一步修改这些类的设计,让数据存储与特定账号关联
if (OrderInfoWs.ORDERINFOWS_CHANNEL.equals(channel)) {
OrderInfoWs.handleEvent(response, redisUtils, account.name());
+// TradeRequestParam tradeRequestParam = OrderInfoWs.handleEvent(response, redisUtils, account.name());
+// TradeOrderWs.orderZhiYingEvent(webSocketClient, tradeRequestParam);
}else if (AccountWs.ACCOUNTWS_CHANNEL.equals(channel)) {
AccountWs.handleEvent(response, account.name());
-// String side = caoZuoService.caoZuo(account.name());
-// TradeOrderWs.orderEvent(webSocketClient, side, account.name());
} else if (PositionsWs.POSITIONSWS_CHANNEL.equals(channel)) {
PositionsWs.handleEvent(response, account.name());
} else if (BalanceAndPositionWs.CHANNEL_NAME.equals(channel)) {
@@ -474,7 +486,7 @@
}
int attempt = 0;
- int maxAttempts = 5;
+ int maxAttempts = 3;
long delayMs = 1000;
while (attempt < maxAttempts && !isConnected.get()) {
--
Gitblit v1.9.1