From a2532aafed1eaeee130f01f3fde90276a8ea040b Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Sun, 14 Dec 2025 14:16:26 +0800
Subject: [PATCH] feat(okxNewPrice): 调整平仓收益比例并增加手续费和资金费用计算
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/PositionsWs.java | 74 +++++++++++++++++++------------------
1 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/PositionsWs.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/PositionsWs.java
index 46ce86b..0af1d7d 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/PositionsWs.java
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/PositionsWs.java
@@ -35,14 +35,14 @@
String connId = MallUtils.getOrderNum(POSITIONSWS_CHANNEL);
JSONObject jsonObject = WsParamBuild.buildJsonObject(connId, option, argsArray);
webSocketClient.send(jsonObject.toJSONString());
- log.info("发送持仓频道频道:{}", option);
+// log.info("发送持仓频道频道:{}", option);
} catch (Exception e) {
log.error("订阅持仓频道频道构建失败", e);
}
}
public static void initEvent(JSONObject response) {
- log.info("订阅成功,数据初始化: {}", response.getJSONObject("arg"));
+// log.info("订阅成功,数据初始化: {}", response.getJSONObject("arg"));
JSONObject arg = response.getJSONObject("arg");
initParam(arg);
}
@@ -50,11 +50,11 @@
public static void handleEvent(JSONObject response) {
- log.info("开始执行PositionsWs......");
+// log.info("开始执行PositionsWs......");
try {
JSONArray dataArray = response.getJSONArray("data");
if (dataArray == null || dataArray.isEmpty()) {
- log.info("账户持仓频道数据为空,已当前价买入,并且初始化网格");
+// log.info("账户持仓频道数据为空,已当前价买入,并且初始化网格");
JSONObject posData = new JSONObject();
initParam(posData);
return;
@@ -64,38 +64,38 @@
JSONObject posData = dataArray.getJSONObject(i);
String instId = posData.getString("instId");
if (CoinEnums.HE_YUE.getCode().equals(instId)) {
- log.info("查询到账户{}持仓数据",CoinEnums.HE_YUE.getCode());
- String mgnMode = posData.getString("mgnMode");
- String posSide = posData.getString("posSide");
- String pos = posData.getString("pos");
- String avgPx = posData.getString("avgPx");
- String upl = posData.getString("upl");
- String uplRatio = posData.getString("uplRatio");
- String lever = posData.getString("lever");
- String liqPx = posData.getString("liqPx");
- String markPx = posData.getString("markPx");
- String imr = posData.getString("imr");
- String mgnRatio = posData.getString("mgnRatio");
- String mmr = posData.getString("mmr");
- String notionalUsd = posData.getString("notionalUsd");
- String ccy = posData.getString("ccy");
- String last = posData.getString("last");
- String idxPx = posData.getString("idxPx");
- String bePx = posData.getString("bePx");
- String realizedPnl = posData.getString("realizedPnl");
- String settledPnl = posData.getString("settledPnl");
- log.info(
- "账户持仓频道-产品类型: {}, 保证金模式: {}, 持仓方向: {}, 持仓数量: {}, 开仓平均价: {}, "
- + "未实现收益: {}, 未实现收益率: {}, 杠杆倍数: {}, 预估强平价: {}, 初始保证金: {}, "
- + "维持保证金率: {}, 维持保证金: {}, 以美金价值为单位的持仓数量: {}, 占用保证金的币种: {}, "
- + "最新成交价: {}, 最新指数价格: {}, 盈亏平衡价: {}, 已实现收益: {}, 累计已结算收益: {}"
- + "最新标记价格: {}",
- instId, mgnMode, posSide, pos, avgPx,
- upl, uplRatio, lever, liqPx, imr,
- mgnRatio, mmr, notionalUsd, ccy,
- last, idxPx, bePx, realizedPnl, settledPnl,
- markPx
- );
+// log.info("查询到账户{}持仓数据",CoinEnums.HE_YUE.getCode());
+// String mgnMode = posData.getString("mgnMode");
+// String posSide = posData.getString("posSide");
+// String pos = posData.getString("pos");
+// String avgPx = posData.getString("avgPx");
+// String upl = posData.getString("upl");
+// String uplRatio = posData.getString("uplRatio");
+// String lever = posData.getString("lever");
+// String liqPx = posData.getString("liqPx");
+// String markPx = posData.getString("markPx");
+// String imr = posData.getString("imr");
+// String mgnRatio = posData.getString("mgnRatio");
+// String mmr = posData.getString("mmr");
+// String notionalUsd = posData.getString("notionalUsd");
+// String ccy = posData.getString("ccy");
+// String last = posData.getString("last");
+// String idxPx = posData.getString("idxPx");
+// String bePx = posData.getString("bePx");
+// String realizedPnl = posData.getString("realizedPnl");
+// String settledPnl = posData.getString("settledPnl");
+// log.info(
+// "账户持仓频道-产品类型: {}, 保证金模式: {}, 持仓方向: {}, 持仓数量: {}, 开仓平均价: {}, "
+// + "未实现收益: {}, 未实现收益率: {}, 杠杆倍数: {}, 预估强平价: {}, 初始保证金: {}, "
+// + "维持保证金率: {}, 维持保证金: {}, 以美金价值为单位的持仓数量: {}, 占用保证金的币种: {}, "
+// + "最新成交价: {}, 最新指数价格: {}, 盈亏平衡价: {}, 已实现收益: {}, 累计已结算收益: {}"
+// + "最新标记价格: {}",
+// instId, mgnMode, posSide, pos, avgPx,
+// upl, uplRatio, lever, liqPx, imr,
+// mgnRatio, mmr, notionalUsd, ccy,
+// last, idxPx, bePx, realizedPnl, settledPnl,
+// markPx
+// );
initParam(posData);
}
@@ -114,6 +114,8 @@
WsMapBuild.saveBigDecimalToMap(POSITIONSWSMAP, "markPx", WsMapBuild.parseBigDecimalSafe(posData.getString("markPx")));
WsMapBuild.saveBigDecimalToMap(POSITIONSWSMAP, "bePx", WsMapBuild.parseBigDecimalSafe(posData.getString("bePx")));
WsMapBuild.saveBigDecimalToMap(POSITIONSWSMAP, "realizedPnl", WsMapBuild.parseBigDecimalSafe(posData.getString("realizedPnl")));
+ WsMapBuild.saveBigDecimalToMap(POSITIONSWSMAP, "fee", WsMapBuild.parseBigDecimalSafe(posData.getString("fee")));
+ WsMapBuild.saveBigDecimalToMap(POSITIONSWSMAP, "fundingFee", WsMapBuild.parseBigDecimalSafe(posData.getString("fundingFee")));
WsMapBuild.saveBigDecimalToMap(POSITIONSWSMAP, CoinEnums.READY_STATE.name(), WsMapBuild.parseBigDecimalSafe(CoinEnums.READY_STATE_YES.getCode()));
}
--
Gitblit v1.9.1