From 66e31450df4d7c5842d7c6550fb3c081f870ce2f Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 29 Jun 2026 11:47:53 +0800
Subject: [PATCH] 止损追单逻辑(多仓/空仓对称): 触发 → 查询 → 计算 → 下单 清理:取消相邻网格旧挂单 + 取消最远止盈单 一句话总结:每次止损触发补回 quantity*2 张,但总持仓不超 maxPositionSize,也不再累加放大。
---
src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionClosesChannelHandler.java | 19 +++++++------------
1 files changed, 7 insertions(+), 12 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 3ca98ff..c58ea39 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
@@ -9,18 +9,7 @@
import java.math.BigDecimal;
/**
- * 平仓频道处理器。
- *
- * <h3>数据用途</h3>
- * 每笔平仓发生时推送 pnl(盈亏金额),累加到 {@code cumulativePnl} 用于判断策略停止条件:
- * cumulativePnl ≥ overallTp(达到止盈目标)或 ≤ -maxLoss(超过亏损上限)。
- * 止盈由 Gate 服务端条件单自动触发,平仓后仓位变为 0,盈亏通过本频道推送。
- *
- * <h3>推送字段</h3>
- * contract, side(long / short), pnl(该次平仓的盈亏,如 "+0.2" 或 "-0.1")
- *
- * <h3>注意</h3>
- * 平仓盈亏来自服务器端,不受本地计算误差影响。这是策略停止的唯一盈亏判断来源。
+ * 平仓频道处理器(futures.position_closes),接收平仓盈亏推送并回调 {@link GateGridTradeService#onPositionClose}。
*
* @author Administrator
*/
@@ -29,6 +18,12 @@
private static final String CHANNEL_NAME = "futures.position_closes";
+ /**
+ * @param apiKey Gate API v4 密钥,用于签名认证
+ * @param apiSecret Gate API v4 签名密钥
+ * @param contract 合约名称(如 ETH_USDT)
+ * @param gridTradeService 网格交易策略服务实例
+ */
public PositionClosesChannelHandler(String apiKey, String apiSecret,
String contract,
GateGridTradeService gridTradeService) {
--
Gitblit v1.9.1