From 6a51883c6d96702df7e1df023b3ad3e0fd575b16 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 17 Dec 2025 16:15:33 +0800
Subject: [PATCH] feat(okx): 实现新的价格WebSocket客户端并优化量化操作
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 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 fb46a4d..9328774 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
@@ -9,8 +9,6 @@
import com.xcong.excoin.modules.okxNewPrice.okxWs.wanggeList.WangGeListQueue;
import com.xcong.excoin.modules.okxNewPrice.okxWs.wanggeList.WangGeListService;
import com.xcong.excoin.modules.okxNewPrice.utils.WsMapBuild;
-import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeQueue;
-import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeService;
import com.xcong.excoin.rabbit.pricequeue.AscBigDecimal;
import com.xcong.excoin.rabbit.pricequeue.DescBigDecimal;
import com.xcong.excoin.utils.RedisUtils;
@@ -34,7 +32,6 @@
@RequiredArgsConstructor
public class CaoZuoServiceImpl implements CaoZuoService {
- private final WangGeService wangGeService;
private final WangGeListService wangGeListService;
private final RedisUtils redisUtils;
@@ -87,7 +84,29 @@
? BigDecimal.ZERO : PositionsWs.getAccountMap(positionAccountName).get(CoinEnums.READY_STATE.name());
if (WsMapBuild.parseBigDecimalSafe(CoinEnums.READY_STATE_YES.getCode()).compareTo(positionsReadyState) != 0) {
log.info("仓位{}通道未就绪,取消发送",positionAccountName);
- return null;
+ // 判断是否保证金超标
+ if (PositionsWs.getAccountMap(positionAccountName).get("imr") == null){
+ log.error("没有获取到持仓信息,等待初始化......");
+ return null;
+ }
+ BigDecimal ordFrozImr = PositionsWs.getAccountMap(positionAccountName).get("imr");
+ BigDecimal totalOrderUsdt = WsMapBuild.parseBigDecimalSafe(AccountWs.getAccountMap(accountName).get(CoinEnums.TOTAL_ORDER_USDT.name()));
+ if (ordFrozImr.compareTo(totalOrderUsdt) >= 0){
+ log.error("已满仓......");
+ return OrderParamEnums.HOLDING.getValue();
+ }
+ if (PositionsWs.getAccountMap(positionAccountName).get("pos") == null){
+ log.error("没有获取到持仓信息,等待初始化......");
+ return null;
+ }
+ BigDecimal pos = PositionsWs.getAccountMap(positionAccountName).get("pos");
+ if (BigDecimal.ZERO.compareTo( pos) >= 0) {
+ log.error("持仓数量为零,进行初始化订单");
+ return OrderParamEnums.INIT.getValue();
+ }else{
+ log.error("仓位有持仓,等待持仓更新");
+ return null;
+ }
}
// 系统设置的开关,等于冷静中,则代表不开仓
String outStr = InstrumentsWs.getAccountMap(accountName).get(CoinEnums.OUT.name());
--
Gitblit v1.9.1