From f29b91353709f8ccc441216629804ee85f6a74c1 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 15 Dec 2025 09:40:57 +0800
Subject: [PATCH] feat(wangge): 调整网格间距默认值

---
 src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java |   16 +++++++++++++---
 1 files changed, 13 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 3d35ad0..107fc4a 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
@@ -128,7 +128,6 @@
             // 处理订单价格在队列中的情况
             String orderPrice = OrderInfoWs.ORDERINFOWSMAP.get("orderPrice");
             handleOrderPriceInQueues(orderPrice, queueKaiCang, queuePingCang);
-            WsMapBuild.saveStringToMap(OrderInfoWs.ORDERINFOWSMAP, "orderPrice", String.valueOf(markPx));
             // 判断是加仓还是减仓
             if (avgPx.compareTo(markPx) > 0) {
                 log.info("开始加仓...");
@@ -140,6 +139,7 @@
                 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("加仓参数准备成功......");
@@ -162,10 +162,18 @@
                 AscBigDecimal pingCang = queuePingCang.peek();
                 if (pingCang != null && markPx.compareTo(pingCang.getValue()) >= 0 && avgPx.compareTo(pingCang.getValue()) < 0) {
                     log.info("开始减仓...平仓队列价格小于当前价格{}<={}", pingCang.getValue(), markPx);
-                    // 判断当前是否盈利
+                    // 手续费
+                    BigDecimal feeValue = PositionsWs.POSITIONSWSMAP.get("fee").multiply(new BigDecimal("2"));
+                    // 资金费用
+                    BigDecimal fundingFeeValue = PositionsWs.POSITIONSWSMAP.get("fundingFee");
+                    //未实现收益
                     BigDecimal uplValue = PositionsWs.POSITIONSWSMAP.get("upl");
-                    BigDecimal imr = PositionsWs.POSITIONSWSMAP.get("imr");
+                    //已实现收益
                     BigDecimal realizedPnlValue = PositionsWs.POSITIONSWSMAP.get("realizedPnl");
+                    realizedPnlValue = realizedPnlValue.add(feeValue).add(fundingFeeValue);
+
+                    //持仓保证金
+                    BigDecimal imr = PositionsWs.POSITIONSWSMAP.get("imr");
                     String pingCangImr = InstrumentsWs.INSTRUMENTSWSMAP.get(CoinEnums.PING_CANG_SHOUYI.name());
                     BigDecimal imrValue = imr.multiply(new BigDecimal(pingCangImr));
 
@@ -173,6 +181,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);
@@ -180,6 +189,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