Administrator
7 days ago 985c037714be0b53396b6f738c3737945d8d6437
fix(gateApi): 修复双边持仓跨度计算逻辑

- 修正了多空双边持仓时价格差值的计算方式,使用绝对值比较
- 更新了日志信息格式,显示绝对值差额而非原始差额
- 确保当价格差距超过阈值时正确触发重启条件
1 files modified
6 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -1356,11 +1356,11 @@
        String reason = "";
        if (hasLong && hasShort) {
            // 多空双边持仓:多均价 − 空均价 > span × step
            BigDecimal gap = longAvgPrice.subtract(shortAvgPrice);
            // 多空双边持仓:|多均价 − 空均价| > span × step
            BigDecimal gap = shortAvgPrice.subtract(longAvgPrice);
            if (gap.compareTo(threshold) >= 0) {
                shouldRestart = true;
                reason = StrUtil.format("双边跨度 多均价:{} − 空均价:{} = {} > {} (span:{}×step:{})",
                reason = StrUtil.format("双边跨度 |多均价:{} − 空均价:{}| = {} >= {} (span:{}×step:{})",
                        longAvgPrice, shortAvgPrice, gap, threshold, span, step);
            }
        } else if (hasLong) {