From 377012b130a26728bed009a228076e72cd01f2f8 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 11 May 2026 16:57:34 +0800
Subject: [PATCH] refactor(gateApi): 优化网格交易逻辑和止盈策略

---
 src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionClosesChannelHandler.java |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionClosesChannelHandler.java b/src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionClosesChannelHandler.java
index 32615b2..3ca98ff 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionClosesChannelHandler.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionClosesChannelHandler.java
@@ -35,6 +35,24 @@
         super(CHANNEL_NAME, apiKey, apiSecret, contract, gridTradeService);
     }
 
+    /**
+     * 处理平仓推送消息。
+     *
+     * <h3>数据提取</h3>
+     * result 数组中每个元素包含:
+     * <ul>
+     *   <li>contract:合约名称</li>
+     *   <li>side:平仓方向("long" / "short")</li>
+     *   <li>pnl:本次平仓的盈亏金额(字符串格式,如 "+0.2" / "-0.1")</li>
+     * </ul>
+     *
+     * <h3>数据处理</h3>
+     * 按合约名称过滤 → 提取 pnl 和 side → 调用 gridTradeService.onPositionClose() 累加盈亏。
+     * pnl 来自服务端,不受本地计算误差影响。
+     *
+     * @param response WebSocket 推送的完整 JSON
+     * @return true 表示已处理(匹配成功)
+     */
     @Override
     public boolean handleMessage(JSONObject response) {
         if (!CHANNEL_NAME.equals(response.getString("channel"))) {

--
Gitblit v1.9.1