fix(okx): 修复OKX交易执行器和WebSocket客户端配置问题
- 在OkxTradeExecutor中添加posSide参数以支持双向持仓模式
- 修复size参数的符号问题,确保传给OKX的值为正数
- 调整OkxWebSocketClientManager中的网格交易参数配置
- 将gridRate从0.03调整为0.0025
- 将baseQuantity和quantity从15调整为1
| | |
| | | executor.execute(() -> { |
| | | try { |
| | | String side = isLong ? "buy" : "sell"; |
| | | String posSide = isLong ? "long" : "short"; |
| | | // OKX sz 必须为正数,strategy 层传入的负数需转正 |
| | | String absSz = size.startsWith("-") ? size.substring(1) : size; |
| | | |
| | | JSONObject body = new JSONObject(); |
| | | body.put("instId", contract); |
| | | body.put("tdMode", "cross"); |
| | | body.put("side", side); |
| | | body.put("posSide", posSide); // 双向持仓模式必须指定 |
| | | body.put("ordType", "trigger"); // 计划委托 = 触发后开仓 |
| | | body.put("sz", size); |
| | | body.put("sz", absSz); |
| | | body.put("triggerPx", triggerPrice.stripTrailingZeros().toPlainString()); |
| | | body.put("triggerPxType", "last"); |
| | | body.put("orderPx", "-1"); // OKX 使用 orderPx,非 ordPx |
| | |
| | | .leverage("100") |
| | | .marginMode("cross") |
| | | .positionMode("long_short_mode") |
| | | .gridRate(new BigDecimal("0.003")) |
| | | .gridRate(new BigDecimal("0.0025")) |
| | | .expectedProfit(new BigDecimal("25")) |
| | | .maxLoss(new BigDecimal("15")) |
| | | .baseQuantity("15") |
| | | .quantity("15") |
| | | .baseQuantity("1") |
| | | .quantity("1") |
| | | .restartGridSpan(6) |
| | | .maxPositionSize(2) |
| | | .priceScale(2) |