| | |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Gate 策略配置 DTO,用于 Web 控制面板参数传递。 |
| | |
| | | .placeExcessTakeProfit(config.isPlaceExcessTakeProfit()) |
| | | .build(); |
| | | } |
| | | |
| | | /** |
| | | * 所有可调参数的扁平快照 — stats 埋点 + STRATEGY_START payload 用。 |
| | | * 新增参数只需在此方法加一行,无需修改 stats 消费者。 |
| | | */ |
| | | public Map<String, Object> toParamsMap() { |
| | | Map<String, Object> m = new LinkedHashMap<>(); |
| | | m.put("contract", contract); |
| | | m.put("leverage", leverage); |
| | | m.put("gridRate", gridRate); |
| | | m.put("expectedProfit", expectedProfit); |
| | | m.put("maxLoss", maxLoss); |
| | | m.put("baseQuantity", baseQuantity); |
| | | m.put("quantity", quantity); |
| | | m.put("maxPositionSize", maxPositionSize); |
| | | m.put("stopLossCount", stopLossCount); |
| | | m.put("takeProfitGridSpan", takeProfitGridSpan); |
| | | m.put("priceDriveEnabled", priceDriveEnabled); |
| | | m.put("rounds", rounds); |
| | | m.put("stopLossCountMode", stopLossCountMode); |
| | | m.put("addPositionInterval", addPositionInterval); |
| | | m.put("addPositionQuantity", addPositionQuantity); |
| | | m.put("maxPositionPerSide", maxPositionPerSide); |
| | | m.put("addPositionStartThreshold", addPositionStartThreshold); |
| | | m.put("placeExcessTakeProfit", placeExcessTakeProfit); |
| | | return m; |
| | | } |
| | | |
| | | /** |
| | | * 带默认值的工厂方法 — 统一 Manager 和 HTML 的默认值入口。 |
| | | */ |
| | | public static GateConfigDTO defaultsFor(String apiKey) { |
| | | return GateConfigDTO.builder() |
| | | .apiKey(apiKey) |
| | | .contract("ETH_USDT") |
| | | .leverage("100") |
| | | .marginMode("cross") |
| | | .positionMode("dual") |
| | | .gridRate(new BigDecimal("0.005")) |
| | | .expectedProfit(new BigDecimal("0.15")) |
| | | .maxLoss(new BigDecimal("1.5")) |
| | | .baseQuantity("2") |
| | | .quantity("2") |
| | | .maxPositionSize(4) |
| | | .stopLossCount(0) |
| | | .takeProfitGridSpan(2) |
| | | .restartGridSpan(0) |
| | | .priceScale(1) |
| | | .contractMultiplier(new BigDecimal("0.001")) |
| | | .unrealizedPnlPriceMode("LAST_PRICE") |
| | | .isProduction(true) |
| | | .priceDriveEnabled(true) |
| | | .rounds(0) |
| | | .stopLossCountMode("dual") |
| | | .addPositionInterval(3) |
| | | .addPositionQuantity(1) |
| | | .maxPositionPerSide(0) |
| | | .addPositionStartThreshold(1) |
| | | .placeExcessTakeProfit(false) |
| | | .build(); |
| | | } |
| | | } |