From 5551bdf6d3311e2eb9af7cc7c0c28c46629d7324 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 14 May 2026 12:59:40 +0800
Subject: [PATCH] refactor(gateApi): 优化网格交易服务的订单管理和止盈逻辑
---
src/main/java/com/xcong/excoin/modules/gateApi/GateTradeExecutor.java | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateTradeExecutor.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateTradeExecutor.java
index 9f155e6..ee5151c 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateTradeExecutor.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateTradeExecutor.java
@@ -108,7 +108,7 @@
* @param onSuccess 成交成功回调(可为 null)
* @param onFailure 成交失败回调(可为 null)
*/
- public void openLong(String quantity, Runnable onSuccess, Runnable onFailure) {
+ public void openLong(String quantity, Consumer<String> onSuccess, Runnable onFailure) {
openPosition(quantity, "t-grid-long", "开多", onSuccess, onFailure);
}
@@ -119,7 +119,7 @@
* @param onSuccess 成交成功回调(可为 null)
* @param onFailure 成交失败回调(可为 null)
*/
- public void openShort(String quantity, Runnable onSuccess, Runnable onFailure) {
+ public void openShort(String quantity, Consumer<String> onSuccess, Runnable onFailure) {
openPosition(quantity, "t-grid-short", "开空", onSuccess, onFailure);
}
@@ -132,7 +132,7 @@
* @param onSuccess 成功回调
* @param onFailure 失败回调
*/
- private void openPosition(String size, String text, String label, Runnable onSuccess, Runnable onFailure) {
+ private void openPosition(String size, String text, String label, Consumer<String> onSuccess, Runnable onFailure) {
executor.execute(() -> {
try {
FuturesOrder order = new FuturesOrder();
@@ -143,8 +143,9 @@
order.setText(text);
FuturesOrder result = futuresApi.createFuturesOrder(SETTLE, order, null);
log.info("[TradeExec] {}成功, 价格:{}, id:{}", label, result.getFillPrice(), result.getId());
+ String orderId = String.valueOf(result.getId());
if (onSuccess != null) {
- onSuccess.run();
+ onSuccess.accept(orderId);
}
} catch (Exception e) {
log.error("[TradeExec] {}失败", label, e);
--
Gitblit v1.9.1