From 7a49fb32bd836a2ed6f9879e26dd98a817c7c1ee Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 22 Jul 2026 16:18:16 +0800
Subject: [PATCH] feat(gate): 添加策略运行轮数限制功能
---
src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 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 88f0a48..31cc1f8 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
@@ -107,8 +107,10 @@
private final int stopLossCount;
/** 止盈网格跨度:相邻止盈单跨越的网格数量,默认 2(即隔一格挂一个止盈单) */
private final int takeProfitGridSpan;
- /** 价格驱动开关:true=启用K线推送中的价格驱动逻辑,false=禁用。默认 false */
+ /** 价格驱动开关:true=启用K线推送中的价格驱动逻辑,false=禁用。默认 true */
private final boolean priceDriveEnabled;
+ /** 策略运行轮数:达到盈利后重启算一轮,达到上限后不再重启。0=不限轮数 */
+ private final int rounds;
/** 网格绝对步长(shortBaseEntryPrice × gridRate),运行时由队列生成逻辑设置 */
private BigDecimal step;
/** 网格元素列表,由队列初始化时同步填充,包含完整的多空仓挂单状态 */
@@ -143,6 +145,7 @@
this.stopLossCount = builder.stopLossCount;
this.takeProfitGridSpan = builder.takeProfitGridSpan;
this.priceDriveEnabled = builder.priceDriveEnabled;
+ this.rounds = builder.rounds;
}
// ==================== REST/WS 地址 ====================
@@ -236,6 +239,8 @@
public int getTakeProfitGridSpan() { return takeProfitGridSpan; }
/** @return 价格驱动开关:true=启用K线推送中的价格驱动逻辑,false=禁用 */
public boolean isPriceDriveEnabled() { return priceDriveEnabled; }
+ /** @return 策略运行轮数上限,0=不限 */
+ public int getRounds() { return rounds; }
// ==================== 运行时参数 ====================
@@ -334,6 +339,8 @@
private int takeProfitGridSpan = 2;
/** 价格驱动开关:true=启用K线推送中的价格驱动逻辑,false=禁用。默认 true */
private boolean priceDriveEnabled = true;
+ /** 策略运行轮数上限,0=不限轮数。默认 0 */
+ private int rounds = 0;
/** 设置 API Key */
public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; }
@@ -383,6 +390,8 @@
public Builder takeProfitGridSpan(int takeProfitGridSpan) { this.takeProfitGridSpan = takeProfitGridSpan; return this; }
/** 设置价格驱动开关:true=启用K线推送中的价格驱动逻辑,false=禁用 */
public Builder priceDriveEnabled(boolean priceDriveEnabled) { this.priceDriveEnabled = priceDriveEnabled; return this; }
+ /** 设置策略运行轮数上限:达到盈利后重启计数,达到此值后不再重启。0=不限 */
+ public Builder rounds(int rounds) { this.rounds = rounds; return this; }
public GateConfig build() {
return new GateConfig(this);
--
Gitblit v1.9.1