Administrator
4 days ago 01da1f754426a1285fc20b9cf1b80672b16d8814
src/main/java/com/xcong/excoin/modules/gateApi/wsHandler/handler/PositionClosesChannelHandler.java
@@ -36,21 +36,27 @@
    @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 item = resultArray.getJSONObject(i);
                if (!getContract().equals(item.getString("contract"))) continue;
                if (!getContract().equals(item.getString("contract"))) {
                    continue;
                }
                BigDecimal pnl = new BigDecimal(item.getString("pnl"));
                String side = item.getString("side");
                log.info("[{}] side:{}, pnl:{}", CHANNEL_NAME, side, pnl);
                log.info("[{}] 平仓更新, 方向:{}, 盈亏:{}", CHANNEL_NAME, side, pnl);
                if (getGridTradeService() != null) {
                    getGridTradeService().onPositionClose(getContract(), side, pnl);
                }
            }
        } catch (Exception e) { log.error("[{}] handle fail", CHANNEL_NAME, e); }
        } catch (Exception e) { log.error("[{}] 处理数据失败", CHANNEL_NAME, e); }
        return true;
    }
}