From 30b0f674ea67f8b113d25b8fd0b9eeb8d01cdf79 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Sun, 14 Dec 2025 13:45:08 +0800
Subject: [PATCH] fix(okxNewPrice): 调整交易参数默认值

---
 src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java |    9 ++++++---
 1 files changed, 6 insertions(+), 3 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 7abe812..bf8443c 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
@@ -46,7 +46,8 @@
             log.info("账户通道未就绪,取消发送");
             return null;
         }
-        BigDecimal positionsReadyState = PositionsWs.POSITIONSWSMAP.get(CoinEnums.READY_STATE.name());
+        BigDecimal positionsReadyState = PositionsWs.POSITIONSWSMAP.get(CoinEnums.READY_STATE.name()) == null
+                ? BigDecimal.ZERO : PositionsWs.POSITIONSWSMAP.get(CoinEnums.READY_STATE.name());
         if (WsMapBuild.parseBigDecimalSafe(CoinEnums.READY_STATE_YES.getCode()).compareTo(positionsReadyState) != 0) {
             log.info("仓位通道未就绪,取消发送");
             return null;
@@ -127,18 +128,18 @@
             // 处理订单价格在队列中的情况
             String orderPrice = OrderInfoWs.ORDERINFOWSMAP.get("orderPrice");
             handleOrderPriceInQueues(orderPrice, queueKaiCang, queuePingCang);
-            boolean orderPriceFlag = WsMapBuild.saveStringToMap(OrderInfoWs.ORDERINFOWSMAP, "orderPrice", String.valueOf(markPx));
             // 判断是加仓还是减仓
             if (avgPx.compareTo(markPx) > 0) {
                 log.info("开始加仓...");
                 if (queueKaiCang.isEmpty()) {
                     // 队列为空
-                    log.info("开始加仓,但是超出了网格设置...");
+//                    log.info("开始加仓,但是超出了网格设置...");
                     return OrderParamEnums.HOLDING.getValue();
                 }
                 DescBigDecimal kaiCang = queueKaiCang.peek();
                 if (kaiCang != null && markPx.compareTo(kaiCang.getValue()) <= 0 && avgPx.compareTo(kaiCang.getValue()) >= 0) {
                     log.info("开始加仓...开仓队列价格大于当前价格{}>{}", kaiCang.getValue(), markPx);
+                    WsMapBuild.saveStringToMap(OrderInfoWs.ORDERINFOWSMAP, "orderPrice", String.valueOf(markPx));
                     boolean buyCntTimeFlag = buyCntTimeEvent(avgPx, markPx);
                     if (buyCntTimeFlag){
                         log.info("加仓参数准备成功......");
@@ -172,6 +173,7 @@
                         BigDecimal realizedPnlValueZheng = realizedPnlValue.multiply(new BigDecimal("-1"));
                         if (uplValue.compareTo(realizedPnlValue) > 0 && uplValue.compareTo(imrValue.add(realizedPnlValueZheng))  >= 0) {
                             log.info("当前未实现盈亏:{}大于预计收益>{},赚钱咯", uplValue, imrValue);
+                            WsMapBuild.saveStringToMap(OrderInfoWs.ORDERINFOWSMAP, "orderPrice", String.valueOf(markPx));
                             return OrderParamEnums.SELL.getValue();
                         }else{
                             log.info("当前未实现盈亏:{}没有大于预计收益>{},钱在路上了", uplValue, imrValue);
@@ -179,6 +181,7 @@
                         }
                     }else {
                         if (uplValue.compareTo(imrValue)  >= 0) {
+                            WsMapBuild.saveStringToMap(OrderInfoWs.ORDERINFOWSMAP, "orderPrice", String.valueOf(markPx));
                             log.info("当前未实现盈亏:{}大于预计收益>{},赚钱咯", uplValue, imrValue);
                             return OrderParamEnums.SELL.getValue();
                         }else{

--
Gitblit v1.9.1