Administrator
yesterday 5d0e6b7b45630f32100d23ca107a9c74df43db75
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -305,17 +305,20 @@
            if (hasPosition) {
                longActive = true;
                longEntryPrice = entryPrice;
                longPositionSize = size;
                if (!baseLongOpened) {
                    longPositionSize = size;
                    longBaseEntryPrice = entryPrice;
                    baseLongOpened = true;
                    log.info("[Gate] 基底多成交价: {}", longBaseEntryPrice);
                    tryGenerateQueues();
                } else {
                } else if (size.compareTo(longPositionSize) > 0) {
                    longPositionSize = size;
                    BigDecimal tpPrice = entryPrice.multiply(BigDecimal.ONE.add(config.getGridRate())).setScale(1, RoundingMode.HALF_UP);
                    executor.placeTakeProfit(tpPrice,
                            FuturesPriceTrigger.RuleEnum.NUMBER_1, ORDER_TYPE_CLOSE_LONG, negate(config.getQuantity()));
                    log.info("[Gate] 多单止盈已设, entry:{}, tp:{}, size:{}", entryPrice, tpPrice, negate(config.getQuantity()));
                } else {
                    longPositionSize = size;
                }
            } else {
                longActive = false;
@@ -325,17 +328,20 @@
            if (hasPosition) {
                shortActive = true;
                shortEntryPrice = entryPrice;
                shortPositionSize = size.abs();
                if (!baseShortOpened) {
                    shortPositionSize = size.abs();
                    shortBaseEntryPrice = entryPrice;
                    baseShortOpened = true;
                    log.info("[Gate] 基底空成交价: {}", shortBaseEntryPrice);
                    tryGenerateQueues();
                } else {
                } else if (size.abs().compareTo(shortPositionSize) > 0) {
                    shortPositionSize = size.abs();
                    BigDecimal tpPrice = entryPrice.multiply(BigDecimal.ONE.subtract(config.getGridRate())).setScale(1, RoundingMode.HALF_UP);
                    executor.placeTakeProfit(tpPrice,
                            FuturesPriceTrigger.RuleEnum.NUMBER_2, ORDER_TYPE_CLOSE_SHORT, config.getQuantity());
                    log.info("[Gate] 空单止盈已设, entry:{}, tp:{}, size:{}", entryPrice, tpPrice, config.getQuantity());
                } else {
                    shortPositionSize = size.abs();
                }
            } else {
                shortActive = false;
@@ -466,13 +472,7 @@
            BigDecimal step = config.getGridRate();
            for (int i = 1; i <= matched.size(); i++) {
                BigDecimal elem = first.multiply(BigDecimal.ONE.subtract(step.multiply(BigDecimal.valueOf(i)))).setScale(1, RoundingMode.HALF_UP);
                if (longEntryPrice.compareTo(BigDecimal.ZERO) > 0
                        && elem.subtract(longEntryPrice).abs().compareTo(longEntryPrice.multiply(step)) < 0) {
                    log.info("[Gate] 多队列跳过:{}", elem);
                    continue;
                }
                longPriceQueue.add(elem);
                log.info("[Gate] 多队列增加:{}", elem);
            }
            longPriceQueue.sort(BigDecimal::compareTo);
@@ -554,14 +554,7 @@
            BigDecimal step = config.getGridRate();
            for (int i = 1; i <= matched.size(); i++) {
                BigDecimal elem = first.multiply(BigDecimal.ONE.add(step.multiply(BigDecimal.valueOf(i)))).setScale(1, RoundingMode.HALF_UP);
                if (shortEntryPrice.compareTo(BigDecimal.ZERO) > 0
                        && elem.subtract(shortEntryPrice).abs().compareTo(shortEntryPrice.multiply(step)) < 0) {
                    log.info("[Gate] 空队列跳过:{}", elem);
                    continue;
                }
                shortPriceQueue.add(elem);
                log.info("[Gate] 空队列增加:{}", elem);
            }
            shortPriceQueue.sort((a, b) -> b.compareTo(a));