From ef88ea05a24fc03487ec201eaf5c77e51809cc66 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 30 Sep 2026 22:07:35 +0800
Subject: [PATCH] refactor(gateApi): 将基础仓位止盈张数字段类型从整型改为大十进制
---
src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java | 86 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 78 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
index 9afad22..fa70691 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
@@ -121,8 +121,29 @@
private final int maxPositionPerSide;
/** 加仓启动阈值:前N次止损不触发加仓,默认 1(第1次止损不加仓,第2次起按公式计算) */
private final int addPositionStartThreshold;
- /** 超额止盈开关:true=挂单成交后将超出基础仓位的部分挂止盈单(挂在对手第一止损位),默认 false */
- private final boolean placeExcessTakeProfit;
+ /** 止盈挂单模式:关闭 */
+ public static final String EXCESS_TP_OFF = "off";
+ /** 止盈挂单模式:集中止盈(挂在对手第一止损位) */
+ public static final String EXCESS_TP_CONCENTRATED = "concentrated";
+ /** 止盈挂单模式:分散止盈(逐格挂到对手盘止损位) */
+ public static final String EXCESS_TP_DISPERSED = "dispersed";
+
+ /** 止盈挂单模式:off=关闭 / concentrated=集中止盈 / dispersed=分散止盈,默认 off */
+ private final String placeExcessTakeProfit;
+ /** 自定义止损开关:true=启用自定义止损触发价(多空各挂一单),false=使用默认阶梯止损。默认 false */
+ private final boolean dualStopLossEnabled;
+ /** 多仓自定义止损触发价(价格跌至该值触发平多),null/0=未设置 */
+ private final BigDecimal longStopLossPrice;
+ /** 空仓自定义止损触发价(价格涨至该值触发平空),null/0=未设置 */
+ private final BigDecimal shortStopLossPrice;
+ /** 止盈成交触发对向加仓开关:true=启用,false=禁用。默认 false */
+ private final boolean tpTriggerOppositeAddEnabled;
+ /** 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数,0=不启用。默认 0 */
+ private final int tpTriggerOppositeAddQuantity;
+ /** 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数,支持小数。默认 0 */
+ private final BigDecimal baseTakeProfitPerGrid;
+ /** 止盈网格数量:基础仓位止盈挂单的网格数量。默认 0 */
+ private final int baseTakeProfitGridCount;
/** 网格绝对步长(shortBaseEntryPrice × gridRate),运行时由队列生成逻辑设置 */
private BigDecimal step;
/** 网格元素列表,由队列初始化时同步填充,包含完整的多空仓挂单状态 */
@@ -164,6 +185,13 @@
this.maxPositionPerSide = builder.maxPositionPerSide;
this.addPositionStartThreshold = builder.addPositionStartThreshold;
this.placeExcessTakeProfit = builder.placeExcessTakeProfit;
+ this.dualStopLossEnabled = builder.dualStopLossEnabled;
+ this.longStopLossPrice = builder.longStopLossPrice;
+ this.shortStopLossPrice = builder.shortStopLossPrice;
+ this.tpTriggerOppositeAddEnabled = builder.tpTriggerOppositeAddEnabled;
+ this.tpTriggerOppositeAddQuantity = builder.tpTriggerOppositeAddQuantity;
+ this.baseTakeProfitPerGrid = builder.baseTakeProfitPerGrid;
+ this.baseTakeProfitGridCount = builder.baseTakeProfitGridCount;
}
// ==================== REST/WS 地址 ====================
@@ -269,8 +297,22 @@
public int getMaxPositionPerSide() { return maxPositionPerSide; }
/** @return 加仓启动阈值:前N次止损不触发加仓 */
public int getAddPositionStartThreshold() { return addPositionStartThreshold; }
- /** @return 超额止盈开关:true=挂单成交后将超出基础仓位的部分挂止盈单 */
- public boolean isPlaceExcessTakeProfit() { return placeExcessTakeProfit; }
+ /** @return 止盈挂单模式:off=关闭 / concentrated=集中止盈 / dispersed=分散止盈 */
+ public String getPlaceExcessTakeProfit() { return placeExcessTakeProfit; }
+ /** @return 自定义止损开关:true=启用自定义止损触发价,false=使用默认阶梯止损 */
+ public boolean isDualStopLossEnabled() { return dualStopLossEnabled; }
+ /** @return 多仓自定义止损触发价,null/0=未设置 */
+ public BigDecimal getLongStopLossPrice() { return longStopLossPrice; }
+ /** @return 空仓自定义止损触发价,null/0=未设置 */
+ public BigDecimal getShortStopLossPrice() { return shortStopLossPrice; }
+ /** @return 止盈成交触发对向加仓开关:true=启用,false=禁用 */
+ public boolean isTpTriggerOppositeAddEnabled() { return tpTriggerOppositeAddEnabled; }
+ /** @return 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数 */
+ public int getTpTriggerOppositeAddQuantity() { return tpTriggerOppositeAddQuantity; }
+ /** @return 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数 */
+ public BigDecimal getBaseTakeProfitPerGrid() { return baseTakeProfitPerGrid; }
+ /** @return 止盈网格数量:基础仓位止盈挂单的网格数量 */
+ public int getBaseTakeProfitGridCount() { return baseTakeProfitGridCount; }
// ==================== 运行时参数 ====================
@@ -381,8 +423,22 @@
private int maxPositionPerSide = 0;
/** 加仓启动阈值:前N次止损不触发加仓,调整后的 effectiveCount = max(0, count - threshold)。默认 1 */
private int addPositionStartThreshold = 1;
- /** 超额止盈开关:true=挂单成交后将超出基础仓位的部分挂止盈单,默认 false */
- private boolean placeExcessTakeProfit = false;
+ /** 止盈挂单模式:off=关闭 / concentrated=集中止盈 / dispersed=分散止盈,默认 off */
+ private String placeExcessTakeProfit = EXCESS_TP_OFF;
+ /** 自定义止损开关:true=启用自定义止损触发价,false=使用默认阶梯止损。默认 false */
+ private boolean dualStopLossEnabled = false;
+ /** 多仓自定义止损触发价,null=未设置 */
+ private BigDecimal longStopLossPrice;
+ /** 空仓自定义止损触发价,null=未设置 */
+ private BigDecimal shortStopLossPrice;
+ /** 止盈成交触发对向加仓开关:true=启用,false=禁用。默认 false */
+ private boolean tpTriggerOppositeAddEnabled = false;
+ /** 对向加仓挂单数量:止盈成交后在对向挂出的开仓张数,默认 0 */
+ private int tpTriggerOppositeAddQuantity = 0;
+ /** 单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数,默认 0 */
+ private BigDecimal baseTakeProfitPerGrid = BigDecimal.ZERO;
+ /** 止盈网格数量:基础仓位止盈挂单的网格数量,默认 0 */
+ private int baseTakeProfitGridCount = 0;
/** 设置 API Key */
public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; }
@@ -444,8 +500,22 @@
public Builder maxPositionPerSide(int maxPositionPerSide) { this.maxPositionPerSide = maxPositionPerSide; return this; }
/** 设置加仓启动阈值:前N次止损不触发加仓,0=立即启动 */
public Builder addPositionStartThreshold(int addPositionStartThreshold) { this.addPositionStartThreshold = addPositionStartThreshold; return this; }
- /** 设置超额止盈开关:true=挂单成交后将超出基础仓位的部分挂止盈单 */
- public Builder placeExcessTakeProfit(boolean placeExcessTakeProfit) { this.placeExcessTakeProfit = placeExcessTakeProfit; return this; }
+ /** 设置止盈挂单模式:off / concentrated / dispersed */
+ public Builder placeExcessTakeProfit(String placeExcessTakeProfit) { this.placeExcessTakeProfit = placeExcessTakeProfit; return this; }
+ /** 设置自定义止损开关:true=启用自定义止损触发价 */
+ public Builder dualStopLossEnabled(boolean dualStopLossEnabled) { this.dualStopLossEnabled = dualStopLossEnabled; return this; }
+ /** 设置多仓自定义止损触发价 */
+ public Builder longStopLossPrice(BigDecimal longStopLossPrice) { this.longStopLossPrice = longStopLossPrice; return this; }
+ /** 设置空仓自定义止损触发价 */
+ public Builder shortStopLossPrice(BigDecimal shortStopLossPrice) { this.shortStopLossPrice = shortStopLossPrice; return this; }
+ /** 设置止盈成交触发对向加仓开关:true=启用,false=禁用 */
+ public Builder tpTriggerOppositeAddEnabled(boolean tpTriggerOppositeAddEnabled) { this.tpTriggerOppositeAddEnabled = tpTriggerOppositeAddEnabled; return this; }
+ /** 设置对向加仓挂单数量:止盈成交后在对向挂出的开仓张数 */
+ public Builder tpTriggerOppositeAddQuantity(int tpTriggerOppositeAddQuantity) { this.tpTriggerOppositeAddQuantity = tpTriggerOppositeAddQuantity; return this; }
+ /** 设置单格止盈张数:基础仓位止盈挂单时每个网格挂的止盈张数 */
+ public Builder baseTakeProfitPerGrid(BigDecimal baseTakeProfitPerGrid) { this.baseTakeProfitPerGrid = baseTakeProfitPerGrid; return this; }
+ /** 设置止盈网格数量:基础仓位止盈挂单的网格数量 */
+ public Builder baseTakeProfitGridCount(int baseTakeProfitGridCount) { this.baseTakeProfitGridCount = baseTakeProfitGridCount; return this; }
public GateConfig build() {
return new GateConfig(this);
--
Gitblit v1.9.1