| | |
| | | } |
| | | |
| | | // 异步检查盈亏,避免 REST 调用阻塞 WS 心跳导致 Socket closed |
| | | executor.submitTask(this::checkProfitAndReset); |
| | | executor.submitMaintenanceTask(this::checkProfitAndReset); |
| | | |
| | | // 持仓主动对账(节流):WS 持仓推送可能因断线盲区/推送延迟而失真, |
| | | // 导致本地持仓状态与交易所不一致、价格驱动重入迟迟不触发。 |
| | |
| | | if ((state == StrategyState.ACTIVE || state == StrategyState.OPENING) |
| | | && System.currentTimeMillis() - lastPositionSyncTime >= POSITION_SYNC_INTERVAL_MS) { |
| | | lastPositionSyncTime = System.currentTimeMillis(); |
| | | executor.submitTask(this::syncPositionsFromExchange); |
| | | executor.submitMaintenanceTask(this::syncPositionsFromExchange); |
| | | } |
| | | |
| | | if (state == StrategyState.ACTIVE && |
| | |
| | | if (wsClient != null) { |
| | | wsClient.setOnAllSubscribedCallback(() -> { |
| | | if (state == StrategyState.ACTIVE || state == StrategyState.OPENING) { |
| | | executor.submitTask(this::syncPositionsFromExchange); |
| | | executor.submitMaintenanceTask(this::syncPositionsFromExchange); |
| | | } |
| | | }); |
| | | } |