From 01da1f754426a1285fc20b9cf1b80672b16d8814 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Fri, 08 May 2026 15:04:28 +0800
Subject: [PATCH] refactor(gateApi): 重构网格交易服务添加补仓重试机制
---
src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionsChannelHandler.java | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionsChannelHandler.java b/src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionsChannelHandler.java
index 4f0e6e1..16c26e3 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionsChannelHandler.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionsChannelHandler.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.modules.gateApi.GateGridTradeService;
import com.xcong.excoin.modules.gateApi.wsHandler.AbstractPrivateChannelHandler;
+import io.gate.gateapi.models.Position;
import lombok.extern.slf4j.Slf4j;
import java.math.BigDecimal;
@@ -37,17 +38,24 @@
@Override
public boolean handleMessage(JSONObject response) {
- if (!CHANNEL_NAME.equals(response.getString("channel"))) return false;
+ if (!CHANNEL_NAME.equals(response.getString("channel"))) {
+ return false;
+ }
try {
JSONArray resultArray = response.getJSONArray("result");
- if (resultArray == null || resultArray.isEmpty()) return true;
+ if (resultArray == null || resultArray.isEmpty()) {
+ return true;
+ }
for (int i = 0; i < resultArray.size(); i++) {
JSONObject pos = resultArray.getJSONObject(i);
- if (!getContract().equals(pos.getString("contract"))) continue;
- String mode = pos.getString("mode");
+ if (!getContract().equals(pos.getString("contract"))) {
+ continue;
+ }
+ String modeStr = pos.getString("mode");
+ Position.ModeEnum mode = Position.ModeEnum.fromValue(modeStr);
BigDecimal size = new BigDecimal(pos.getString("size"));
BigDecimal entryPrice = new BigDecimal(pos.getString("entry_price"));
- log.info("[{}] 持仓更新, 模式:{}, 数量:{}, 入场价:{}", CHANNEL_NAME, mode, size, entryPrice);
+ log.info("[{}] 持仓更新, 模式:{}, 数量:{}, 入场价:{}", CHANNEL_NAME, modeStr, size, entryPrice);
if (getGridTradeService() != null) {
getGridTradeService().onPositionUpdate(getContract(), mode, size, entryPrice);
}
--
Gitblit v1.9.1