Administrator
2026-08-03 0a61d6060deef857d371af60c5ea551c92e21b12
src/main/java/com/xcong/excoin/modules/gateApi/GateConfig.java
@@ -99,6 +99,18 @@
    private final int priceScale;
    /** 未实现盈亏计价模式:最新价 / 标记价格 */
    private final PnLPriceMode unrealizedPnlPriceMode;
    /** 最大持仓张数(单方向),0=不限制 */
    private final int maxPositionSize;
    /** 策略重启跨度阈值:多空两边止盈触发数量均达到此值后触发重启,0=禁用 */
    private final int restartGridSpan;
    /** 止损阶梯次数:止损触发次数≤该值时挂单量=止损次数,超过后恢复默认逻辑。0=禁用,默认 0 */
    private final int stopLossCount;
    /** 止盈网格跨度:相邻止盈单跨越的网格数量,默认 2(即隔一格挂一个止盈单) */
    private final int takeProfitGridSpan;
    /** 价格驱动开关:true=启用K线推送中的价格驱动逻辑,false=禁用。默认 true */
    private final boolean priceDriveEnabled;
    /** 策略运行轮数:达到盈利后重启算一轮,达到上限后不再重启。0=不限轮数 */
    private final int rounds;
    /** 网格绝对步长(shortBaseEntryPrice × gridRate),运行时由队列生成逻辑设置 */
    private BigDecimal step;
    /** 网格元素列表,由队列初始化时同步填充,包含完整的多空仓挂单状态 */
@@ -128,6 +140,12 @@
        this.contractMultiplier = builder.contractMultiplier;
        this.priceScale = builder.priceScale;
        this.unrealizedPnlPriceMode = builder.unrealizedPnlPriceMode;
        this.maxPositionSize = builder.maxPositionSize;
        this.restartGridSpan = builder.restartGridSpan;
        this.stopLossCount = builder.stopLossCount;
        this.takeProfitGridSpan = builder.takeProfitGridSpan;
        this.priceDriveEnabled = builder.priceDriveEnabled;
        this.rounds = builder.rounds;
    }
    // ==================== REST/WS 地址 ====================
@@ -211,6 +229,18 @@
    public int getPriceScale() { return priceScale; }
    /** @return 未实现盈亏计价模式:LAST_PRICE(最新成交价)/ MARK_PRICE(标记价格) */
    public PnLPriceMode getUnrealizedPnlPriceMode() { return unrealizedPnlPriceMode; }
    /** @return 最大持仓张数(单方向),0=不限制 */
    public int getMaxPositionSize() { return maxPositionSize; }
    /** @return 策略重启跨度阈值:多空两边止盈触发数均达到此值后触发重启,0=禁用 */
    public int getRestartGridSpan() { return restartGridSpan; }
    /** @return 止损阶梯次数:止损触发次数≤该值时挂单量=止损次数,超过后恢复默认逻辑。0=禁用 */
    public int getStopLossCount() { return stopLossCount; }
    /** @return 止盈网格跨度:相邻止盈单跨越的网格数量,默认 2 */
    public int getTakeProfitGridSpan() { return takeProfitGridSpan; }
    /** @return 价格驱动开关:true=启用K线推送中的价格驱动逻辑,false=禁用 */
    public boolean isPriceDriveEnabled() { return priceDriveEnabled; }
    /** @return 策略运行轮数上限,0=不限 */
    public int getRounds() { return rounds; }
    // ==================== 运行时参数 ====================
@@ -299,6 +329,18 @@
        private int priceScale = 1;
        /** 未实现盈亏计价模式,默认 LAST_PRICE(最新成交价) */
        private PnLPriceMode unrealizedPnlPriceMode = PnLPriceMode.LAST_PRICE;
        /** 最大持仓张数(单方向),默认 0=不限制 */
        private int maxPositionSize = 0;
        /** 策略重启跨度阈值:多空两边止盈触发数量均达到此值后触发重启,默认 0=禁用 */
        private int restartGridSpan = 0;
        /** 止损阶梯次数:止损触发次数≤该值时挂单量=止损次数,超过后恢复默认逻辑。0=禁用,默认 0 */
        private int stopLossCount = 0;
        /** 止盈网格跨度:相邻止盈单跨越的网格数量,默认 2 */
        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; }
@@ -338,6 +380,18 @@
        public Builder gridQueueSize(int gridQueueSize) { this.gridQueueSize = gridQueueSize; return this; }
        /** 设置未实现盈亏计价模式 */
        public Builder unrealizedPnlPriceMode(PnLPriceMode mode) { this.unrealizedPnlPriceMode = mode; return this; }
        /** 设置最大持仓张数(单方向),0=不限制 */
        public Builder maxPositionSize(int maxPositionSize) { this.maxPositionSize = maxPositionSize; return this; }
        /** 设置策略重启跨度阈值:多空两边止盈触发数均达到此值后触发重启,0=禁用 */
        public Builder restartGridSpan(int restartGridSpan) { this.restartGridSpan = restartGridSpan; return this; }
        /** 设置止损阶梯次数:止损触发次数≤该值时挂单量=止损次数,超过后恢复默认逻辑。0=禁用 */
        public Builder stopLossCount(int stopLossCount) { this.stopLossCount = stopLossCount; return this; }
        /** 设置止盈网格跨度:相邻止盈单跨越的网格数量,默认 2 */
        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);