| | |
| | | return; |
| | | } |
| | | |
| | | // OPENING 状态下若 WS 仓位已确认但 REST 回调尚未完成,等标记价格推送时重试队列生成 |
| | | if (state == StrategyState.OPENING && |
| | | baseLongOpened && baseShortOpened) { |
| | | tryGenerateQueues(); |
| | | } |
| | | |
| | | |
| | | if (state == StrategyState.ACTIVE && |
| | | !longActive && |
| | |
| | | // ---- 网格队列处理 ---- |
| | | |
| | | private void tryGenerateQueues() { |
| | | if (baseLongOpened && baseShortOpened) { |
| | | // OPENING 状态下若 WS 仓位已确认但 REST 回调尚未完成,等标记价格推送时重试队列生成 |
| | | if (state == StrategyState.OPENING && baseLongOpened && baseShortOpened) { |
| | | // 确保 openLong/openShort 的 REST 回调已完成(WS 推送可能比回调更快到达) |
| | | if (config.getBaseLongTraderParam() == null || config.getBaseShortTraderParam() == null) { |
| | | log.warn("[OKX] 基底REST回调尚未完成, 延后队列生成"); |
| | |
| | | }); |
| | | } |
| | | log.info("[OKX] 止损单已全部挂完, 空仓止损: 2~{}, 多仓止损: -2~-{}", stopCount, stopCount); |
| | | |
| | | // 挂初始条件开仓单 |
| | | GridElement longFirst = GridElement.findById(1); |
| | | if (longFirst != null && !longFirst.isHasLongOrder()) { |
| | | BigDecimal triggerPrice = longFirst.getGridPrice(); |
| | | log.info("[OKX] 挂初始多仓条件单, gridId:1, trigger:{}", triggerPrice); |
| | | placeEntryOrderWithPreFlag(longFirst, true, triggerPrice, config.getBaseQuantity()); |
| | | } |
| | | GridElement shortFirst = GridElement.findById(-1); |
| | | if (shortFirst != null && !shortFirst.isHasShortOrder()) { |
| | | BigDecimal triggerPrice = shortFirst.getGridPrice(); |
| | | log.info("[OKX] 挂初始空仓条件单, gridId:-1, trigger:{}", triggerPrice); |
| | | placeEntryOrderWithPreFlag(shortFirst, false, triggerPrice, negate(config.getBaseQuantity())); |
| | | } |
| | | |
| | | state = StrategyState.ACTIVE; |
| | | } |