| | |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | log.info("[GateMgr] init..."); |
| | | log.info("[管理器] 开始初始化..."); |
| | | |
| | | try { |
| | | config = GateConfig.builder() |
| | | .apiKey("d90ca272391992b8e74f8f92cedb21ec") |
| | | .apiSecret("1861e4f52de4bb53369ea3208d9ede38ece4777368030f96c77d27934c46c274") |
| | | .contract("XAUT_USDT") |
| | | .leverage("30") |
| | | .contract("ETH_USDT") |
| | | .leverage("100") |
| | | .marginMode("cross") |
| | | .positionMode("dual") |
| | | .gridRate(new BigDecimal("0.0035")) |
| | | .gridRate(new BigDecimal("0.002")) |
| | | .overallTp(new BigDecimal("0.5")) |
| | | .maxLoss(new BigDecimal("7.5")) |
| | | .quantity("10") |
| | | .quantity("1") |
| | | .contractMultiplier(new BigDecimal("0.001")) |
| | | .unrealizedPnlPriceMode(GateConfig.PnLPriceMode.LAST_PRICE) |
| | | .isProduction(false) |
| | | .reopenMaxRetries(3) |
| | | .build(); |
| | |
| | | wsClient.addChannelHandler(new PositionClosesChannelHandler( |
| | | config.getApiKey(), config.getApiSecret(), config.getContract(), gridTradeService)); |
| | | wsClient.init(); |
| | | log.info("[GateMgr] ws connected, 3 handlers registered"); |
| | | log.info("[管理器] WS已连接, 已注册 3 个频道处理器"); |
| | | |
| | | gridTradeService.startGrid(); |
| | | } catch (Exception e) { |
| | | log.error("[GateMgr] init fail", e); |
| | | log.error("[管理器] 初始化失败", e); |
| | | } |
| | | } |
| | | |
| | | @PreDestroy |
| | | public void destroy() { |
| | | log.info("[GateMgr] destroy..."); |
| | | log.info("[管理器] 开始销毁..."); |
| | | if (gridTradeService != null) { |
| | | gridTradeService.stopGrid(); |
| | | } |
| | | if (wsClient != null) { |
| | | wsClient.destroy(); |
| | | } |
| | | log.info("[GateMgr] destroyed"); |
| | | log.info("[管理器] 销毁完成"); |
| | | } |
| | | |
| | | public GateKlineWebSocketClient getKlineWebSocketClient() { return wsClient; } |