| | |
| | | private final BigDecimal maxLoss; |
| | | /** 下单数量(合约张数) */ |
| | | private final String quantity; |
| | | /** 基底开仓张数(初始化时多空各开的张数,如 "10") */ |
| | | private final String baseQuantity; |
| | | /** 预期收益(USDT),unrealisedPnl + available > 初始本金 + 此值时重置 */ |
| | | private final BigDecimal expectedProfit; |
| | | /** 是否为生产环境 */ |
| | | private final boolean isProduction; |
| | | /** 补仓最大重试次数 */ |
| | |
| | | private final int priceScale; |
| | | /** 未实现盈亏计价模式:最新价 / 标记价格 */ |
| | | private final PnLPriceMode unrealizedPnlPriceMode; |
| | | /** 最大持仓张数(单方向),0=不限制 */ |
| | | private final int maxPositionSize; |
| | | /** 策略重启跨度阈值:多空两边止盈触发数量均达到此值后触发重启,0=禁用 */ |
| | | private final int restartGridSpan; |
| | | /** 网格绝对步长(shortBaseEntryPrice × gridRate),运行时由队列生成逻辑设置 */ |
| | | private BigDecimal step; |
| | | /** 网格元素列表,由队列初始化时同步填充,包含完整的多空仓挂单状态 */ |
| | |
| | | this.overallTp = builder.overallTp; |
| | | this.maxLoss = builder.maxLoss; |
| | | this.quantity = builder.quantity; |
| | | this.baseQuantity = builder.baseQuantity; |
| | | this.expectedProfit = builder.expectedProfit; |
| | | this.isProduction = builder.isProduction; |
| | | this.reopenMaxRetries = builder.reopenMaxRetries; |
| | | this.gridQueueSize = builder.gridQueueSize; |
| | |
| | | this.contractMultiplier = builder.contractMultiplier; |
| | | this.priceScale = builder.priceScale; |
| | | this.unrealizedPnlPriceMode = builder.unrealizedPnlPriceMode; |
| | | this.maxPositionSize = builder.maxPositionSize; |
| | | this.restartGridSpan = builder.restartGridSpan; |
| | | } |
| | | |
| | | // ==================== REST/WS 地址 ==================== |
| | |
| | | public BigDecimal getMaxLoss() { return maxLoss; } |
| | | /** @return 每次下单的张数(如 "1" 表示 1 张合约) */ |
| | | public String getQuantity() { return quantity; } |
| | | /** @return 基底开仓张数(初始化时多空各开的张数,如 "10") */ |
| | | public String getBaseQuantity() { return baseQuantity; } |
| | | /** @return 预期收益(USDT),unrealisedPnl + available > 初始本金 + 此值时重置 */ |
| | | public BigDecimal getExpectedProfit() { return expectedProfit; } |
| | | /** @return 网格价格队列的容量上限(超出时截断尾部) */ |
| | | public int getGridQueueSize() { return gridQueueSize; } |
| | | |
| | |
| | | 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; } |
| | | |
| | | // ==================== 运行时参数 ==================== |
| | | |
| | |
| | | private BigDecimal maxLoss = new BigDecimal("7.5"); |
| | | /** 每次下单张数,默认 "1" */ |
| | | private String quantity = "1"; |
| | | /** 基底开仓张数,默认 "10"(初始化时多空各开10张) */ |
| | | private String baseQuantity = "10"; |
| | | /** 预期收益(USDT),默认 0.5 */ |
| | | private BigDecimal expectedProfit = new BigDecimal("0.5"); |
| | | /** 是否为生产环境,默认 false(测试网) */ |
| | | private boolean isProduction = false; |
| | | /** 补仓最大重试次数,默认 3 */ |
| | |
| | | private int priceScale = 1; |
| | | /** 未实现盈亏计价模式,默认 LAST_PRICE(最新成交价) */ |
| | | private PnLPriceMode unrealizedPnlPriceMode = PnLPriceMode.LAST_PRICE; |
| | | /** 最大持仓张数(单方向),默认 0=不限制 */ |
| | | private int maxPositionSize = 0; |
| | | /** 策略重启跨度阈值:多空两边止盈触发数量均达到此值后触发重启,默认 0=禁用 */ |
| | | private int restartGridSpan = 0; |
| | | |
| | | /** 设置 API Key */ |
| | | public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; } |
| | |
| | | public Builder maxLoss(BigDecimal maxLoss) { this.maxLoss = maxLoss; return this; } |
| | | /** 设置每次下单张数 */ |
| | | public Builder quantity(String quantity) { this.quantity = quantity; return this; } |
| | | /** 设置基底开仓张数 */ |
| | | public Builder baseQuantity(String baseQuantity) { this.baseQuantity = baseQuantity; return this; } |
| | | /** 设置预期收益(USDT) */ |
| | | public Builder expectedProfit(BigDecimal expectedProfit) { this.expectedProfit = expectedProfit; return this; } |
| | | /** 设置环境(true=实盘生产网 / false=模拟盘测试网) */ |
| | | public Builder isProduction(boolean isProduction) { this.isProduction = isProduction; return this; } |
| | | /** 设置补仓最大重试次数 */ |
| | |
| | | public Builder contractMultiplier(BigDecimal contractMultiplier) { this.contractMultiplier = contractMultiplier; return this; } |
| | | /** 设置价格精度(交易所价格的小数位数,如 1=0.1精度,2=0.01精度) */ |
| | | public Builder priceScale(int priceScale) { this.priceScale = priceScale; return this; } |
| | | /** 设置保证金占初始本金比例上限 */ |
| | | public Builder marginRatioLimit(BigDecimal marginRatioLimit) { this.marginRatioLimit = marginRatioLimit; return this; } |
| | | /** 设置网格队列容量 */ |
| | | 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; } |
| | | |
| | | public GateConfig build() { |
| | | return new GateConfig(this); |