| | |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | log.info("[GateMgr] init..."); |
| | | log.info("[管理器] 开始初始化..."); |
| | | |
| | | try { |
| | | config = GateConfig.builder() |
| | |
| | | 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; } |