| | |
| | | config.isPriceDriveEnabled() && |
| | | longActive == false && |
| | | longPositionSize.compareTo(BigDecimal.ZERO) == 0){ |
| | | processShortGrid(closePrice); |
| | | processLongGrid(closePrice); |
| | | } |
| | | |
| | | |
| | |
| | | config.isPriceDriveEnabled() && |
| | | shortActive == false && |
| | | shortPositionSize.compareTo(BigDecimal.ZERO) == 0){ |
| | | processLongGrid(closePrice); |
| | | processShortGrid(closePrice); |
| | | } |
| | | } |
| | | |
| | |
| | | generateShortQueue(); |
| | | generateLongQueue(); |
| | | updateGridElements(); |
| | | |
| | | GridElement baseGridElement = GridElement.findById(0); |
| | | baseGridElement.setLongOrderId(baseLongTraderParam.getEntryOrderId()); |
| | | baseGridElement.setHasLongOrder(true); |
| | | baseGridElement.setShortOrderId(baseShortTraderParam.getEntryOrderId()); |
| | | baseGridElement.setHasShortOrder(true); |
| | | |
| | | // // 空仓止损对应的多仓止盈:多仓止盈挂在ID=3 |
| | | // int tpGridIdLong = 3; |
| | |
| | | } |
| | | |
| | | |
| | | private void processShortGrid(BigDecimal currentPrice) { |
| | | /** 多仓仓位归零后,在当前价上方最近网格重新挂多单(遍历 totalLongPriceQueue 升序)。 */ |
| | | private void processLongGrid(BigDecimal currentPrice) { |
| | | BigDecimal matched = BigDecimal.ZERO; |
| | | synchronized (totalLongPriceQueue) { |
| | | for (BigDecimal p : totalLongPriceQueue) { |
| | |
| | | |
| | | } |
| | | |
| | | private void processLongGrid(BigDecimal currentPrice) { |
| | | /** 空仓仓位归零后,在当前价下方最近网格重新挂空单(遍历 totalShortPriceQueue 降序)。 */ |
| | | private void processShortGrid(BigDecimal currentPrice) { |
| | | BigDecimal matched = BigDecimal.ZERO; |
| | | synchronized (totalShortPriceQueue) { |
| | | for (BigDecimal p : totalShortPriceQueue) { |
| | |
| | | GridElement finalCancelCursor = cancelCursor; |
| | | executor.cancelConditionalOrder(shortOrderId, oid -> { |
| | | shortEntryTraderIdParam(finalCancelCursor, shortOrderId, false); |
| | | log.info("[Gate] 空仓仓位归零, 取消gridId:{}的多单{}", finalCancelCursor.getId(), shortOrderId); |
| | | log.info("[Gate] 空仓仓位归零, 取消gridId:{}的空单{}", finalCancelCursor.getId(), shortOrderId); |
| | | }); |
| | | } |
| | | } |
| | |
| | | if (!newEntryGrid.isHasShortOrder() && !hasShortOrderAbove){ |
| | | BigDecimal triggerPrice = newEntryGrid.getGridPrice(); |
| | | String size = quantity; |
| | | log.info("[Gate] 空仓仓位归零 gridId:{}, 挂{}基础张多单", |
| | | log.info("[Gate] 空仓仓位归零 gridId:{}, 挂{}基础张空单", |
| | | newEntryGrid.getId(), size); |
| | | newEntryGrid.getShortTraderParam().setQuantity(size); |
| | | placeEntryOrderWithPreFlag(newEntryGrid, false, triggerPrice, |