Administrator
2026-05-21 526dc9bd7e7e71e5e18c4dd966d3996e628ae6fa
fix(gateApi): 更新网格交易盈亏计算逻辑

- 添加未实现盈亏到总盈亏计算中
- 修改日志输出以显示已实现、未实现和合计盈亏
- 更新止盈止损判断条件为总盈亏
- 调整日志信息以显示完整的盈亏详情
1 files modified
14 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -517,13 +517,17 @@
            return;
        }
        cumulativePnl = cumulativePnl.add(pnl);
        log.info("[Gate] 盈亏累加:{}, 方向:{}, 累计:{}", pnl, side, cumulativePnl);
        BigDecimal totalPnl = cumulativePnl.add(unrealizedPnl);
        log.info("[Gate] 盈亏累加:{}, 方向:{}, 已实现:{}, 未实现:{}, 合计:{}",
                pnl, side, cumulativePnl, unrealizedPnl, totalPnl);
        if (cumulativePnl.compareTo(config.getOverallTp()) >= 0) {
            log.info("[Gate] 已达止盈目标 {}→已停止", cumulativePnl);
        if (totalPnl.compareTo(config.getOverallTp()) >= 0) {
            log.info("[Gate] 已达止盈目标(合计{})→已停止, 已实现:{}, 未实现:{}",
                    totalPnl, cumulativePnl, unrealizedPnl);
            state = StrategyState.STOPPED;
        } else if (cumulativePnl.compareTo(config.getMaxLoss().negate()) <= 0) {
            log.info("[Gate] 已达亏损上限 {}→已停止", cumulativePnl);
        } else if (totalPnl.compareTo(config.getMaxLoss().negate()) <= 0) {
            log.info("[Gate] 已达亏损上限(合计{})→已停止, 已实现:{}, 未实现:{}",
                    totalPnl, cumulativePnl, unrealizedPnl);
            state = StrategyState.STOPPED;
        }
    }