From 35ba3e760f1c4a5f21d83aa871d041f440f1d099 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 15 Jun 2026 15:26:05 +0800
Subject: [PATCH] refactor(gateApi): 修改网格交易止损扩展方法参数
---
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 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 1106ed2..93c14be 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -608,7 +608,7 @@
if (shortGridElement.isHasShortOrder() && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0") ){
int filledQty = Integer.parseInt(shortGridElement.getShortTraderParam().getQuantity());
shortEntryTraderIdParam(shortGridElement, null, false);
- extendShortStopLoss(filledQty);
+ extendShortStopLoss(filledQty,shortGridElement.getId());
log.info("[Gate] 空单成交 gridId:{}", filledQty);
// 空仓持仓超过baseQuantity时,从gridId-2开始向外追挂止盈
@@ -646,7 +646,7 @@
int filledQty = Integer.parseInt(longGridElement.getLongTraderParam().getQuantity());
longEntryTraderIdParam(longGridElement, null, false);
- extendLongStopLoss(filledQty);
+ extendLongStopLoss(filledQty,longGridElement.getId());
log.info("[Gate] 多单成交 gridId:{}", filledQty);
// 多仓持仓超过baseQuantity时,从gridId+2开始向外追挂止盈
@@ -745,7 +745,7 @@
// );
// }
- int shortTime = Integer.parseInt(config.getBaseQuantity()) + 1;
+ int shortTime = Integer.parseInt(config.getBaseQuantity()) / Integer.parseInt(config.getQuantity()) + 1;
for (int id = 2; id <= shortTime; id++) {
GridElement elem = GridElement.findById(id);
if (elem == null) {
@@ -768,7 +768,7 @@
}
- int longTime = Integer.parseInt(config.getBaseQuantity()) + 1;
+ int longTime = Integer.parseInt(config.getBaseQuantity()) / Integer.parseInt(config.getQuantity()) + 1;
for (int id = -2; id >= -longTime; id--) {
GridElement elem = GridElement.findById(id);
if (elem == null) {
@@ -1213,7 +1213,7 @@
}
}
- private void extendLongStopLoss(int filledQty) {
+ private void extendLongStopLoss(int filledQty,int gridId) {
int furthestSlId = 0;
for (GridElement e : config.getGridElements()) {
if (e.getLongStopLossOrderId() != null && e.getId() < furthestSlId) {
@@ -1221,7 +1221,7 @@
}
}
if (furthestSlId == 0) {
- furthestSlId = -11;
+ furthestSlId = gridId;
}
log.info("[Gate] 多仓追挂止损, 当前最远止损gridId:{}, 追加{}张", furthestSlId, filledQty);
for (int i = 0; i < filledQty; i++) {
@@ -1246,7 +1246,7 @@
}
}
- private void extendShortStopLoss(int filledQty) {
+ private void extendShortStopLoss(int filledQty, int gridId) {
int furthestSlId = 0;
for (GridElement e : config.getGridElements()) {
if (e.getShortStopLossOrderId() != null && e.getId() > furthestSlId) {
@@ -1254,7 +1254,7 @@
}
}
if (furthestSlId == 0) {
- furthestSlId = 11;
+ furthestSlId = gridId;
}
log.info("[Gate] 空仓追挂止损, 当前最远止损gridId:{}, 追加{}张", furthestSlId, filledQty);
for (int i = 0; i < filledQty; i++) {
--
Gitblit v1.9.1