From 5d0e6b7b45630f32100d23ca107a9c74df43db75 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 11 May 2026 11:58:04 +0800
Subject: [PATCH] refactor(gate): 移除账号标签配置和多账号支持功能
---
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
index d9c2310..5710e88 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/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;
@@ -453,8 +459,10 @@
for (int i = 0; i < matched.size(); i++) {
min = min.multiply(BigDecimal.ONE.subtract(step)).setScale(1, RoundingMode.HALF_UP);
shortPriceQueue.add(min);
+ log.info("[Gate] 空队列增加:{}", min);
}
- shortPriceQueue.sort(BigDecimal::compareTo);
+
+ shortPriceQueue.sort((a, b) -> b.compareTo(a));
log.info("[Gate] 现空队列:{}", shortPriceQueue);
}
@@ -462,21 +470,16 @@
synchronized (longPriceQueue) {
BigDecimal first = longPriceQueue.isEmpty() ? matched.get(matched.size() - 1) : longPriceQueue.get(0);
BigDecimal step = config.getGridRate();
- int added = 0;
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) {
- continue;
- }
longPriceQueue.add(elem);
- added++;
+ log.info("[Gate] 多队列增加:{}", elem);
}
longPriceQueue.sort(BigDecimal::compareTo);
while (longPriceQueue.size() > config.getGridQueueSize()) {
longPriceQueue.remove(longPriceQueue.size() - 1);
}
- log.info("[Gate] 现多队列:{}, 跳过{}个(贴近多仓均价)", longPriceQueue, matched.size() - added);
+ log.info("[Gate] 现多队列:{}", longPriceQueue);
}
}
@@ -538,6 +541,8 @@
for (int i = 0; i < matched.size(); i++) {
max = max.multiply(BigDecimal.ONE.add(step)).setScale(1, RoundingMode.HALF_UP);
longPriceQueue.add(max);
+
+ log.info("[Gate] 多队列增加:{}", max);
}
longPriceQueue.sort(BigDecimal::compareTo);
@@ -547,21 +552,16 @@
synchronized (shortPriceQueue) {
BigDecimal first = shortPriceQueue.isEmpty() ? matched.get(0) : shortPriceQueue.get(0);
BigDecimal step = config.getGridRate();
- int added = 0;
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) {
- continue;
- }
shortPriceQueue.add(elem);
- added++;
+ log.info("[Gate] 空队列增加:{}", elem);
}
shortPriceQueue.sort((a, b) -> b.compareTo(a));
while (shortPriceQueue.size() > config.getGridQueueSize()) {
shortPriceQueue.remove(shortPriceQueue.size() - 1);
}
- log.info("[Gate] 现空队列:{}, 跳过{}个(贴近空仓均价)", shortPriceQueue, matched.size() - added);
+ log.info("[Gate] 现空队列:{}", shortPriceQueue);
}
}
--
Gitblit v1.9.1