From 981a87bd0b06a17064f7b0d2435e96045cc03987 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 25 Jun 2026 15:38:04 +0800
Subject: [PATCH] refactor(okxApi): 简化条件单状态变更回调方法参数

---
 src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java b/src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java
index 703ba16..8a8f974 100644
--- a/src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java
@@ -415,12 +415,12 @@
     /**
      * 自动订单状态变更回调。由 OrdersOkxChannelHandler 调用。
      */
-    public void onAutoOrder(String orderId, String status, String reason, String orderType, String tradeId) {
+    public void onAutoOrder(String orderId, String status, String orderType, String tradeId) {
         if (state == StrategyState.STOPPED) {
             return;
         }
-        log.info("[OKX] 条件单状态变更, id:{}, status:{}, reason:{}, order_type:{}",
-                orderId, status, reason, orderType);
+        log.info("[OKX] 条件单状态变更, id:{}, status:{}, order_type:{}",
+                orderId, status,  orderType);
         if (!"finished".equals(status)) {
             return;
         }
@@ -467,7 +467,8 @@
                 int posSize = queryPositionSize(OkxPosMode.SHORT);
                 extendShortStopLoss(posSize, shortGridElement.getId());
                 accumulatedShortLossCount = 0;
-                log.info("[OKX] 空单成交 gridId:{}, 当前持仓:{}张", filledQty, posSize);
+                log.info("[OKX] 空单成交 gridId:{}, 成交{}张, 当前持仓:{}张",
+                        shortGridElement.getId(), filledQty, posSize);
 
                 BigDecimal shortBaseQty = new BigDecimal(config.getBaseQuantity());
                 BigDecimal shortGridQty = new BigDecimal(config.getQuantity());
@@ -475,8 +476,7 @@
                     BigDecimal shortExcess = BigDecimal.valueOf(posSize).subtract(shortBaseQty);
                     int shortExcessCount = shortExcess.divide(shortGridQty, 0, RoundingMode.DOWN).intValue();
                     for (int i = 0; i < shortExcessCount; i++) {
-                        int tpGridId = shortGridElement.getId() - 2 - i;
-                        if (i > 0) { tpGridId = tpGridId - 1; }
+                        int tpGridId = shortGridElement.getId() - 2 * (i + 1);
                         GridElement tpElem = GridElement.findById(tpGridId);
                         if (tpElem == null || tpElem.getShortTakeProfitOrderId() != null) {
                             continue;
@@ -507,7 +507,8 @@
                 int posSize = queryPositionSize(OkxPosMode.LONG);
                 extendLongStopLoss(posSize, longGridElement.getId());
                 accumulatedLongLossCount = 0;
-                log.info("[OKX] 多单成交 gridId:{}, 当前持仓:{}张", filledQty, posSize);
+                log.info("[OKX] 多单成交 gridId:{}, 成交{}张, 当前持仓:{}张",
+                        longGridElement.getId(), filledQty, posSize);
 
                 BigDecimal longBaseQty = new BigDecimal(config.getBaseQuantity());
                 BigDecimal longGridQty = new BigDecimal(config.getQuantity());
@@ -515,8 +516,7 @@
                     BigDecimal longExcess = BigDecimal.valueOf(posSize).subtract(longBaseQty);
                     int longExcessCount = longExcess.divide(longGridQty, 0, RoundingMode.DOWN).intValue();
                     for (int i = 0; i < longExcessCount; i++) {
-                        int tpGridId = longGridElement.getId() + 2 + i;
-                        if (i > 0) { tpGridId = tpGridId + 1; }
+                        int tpGridId = longGridElement.getId() + 2 * (i + 1);
                         GridElement tpElem = GridElement.findById(tpGridId);
                         if (tpElem == null || tpElem.getLongTakeProfitOrderId() != null) {
                             continue;

--
Gitblit v1.9.1