| | |
| | | private final String contract; |
| | | private final String marginMode; |
| | | private final String accountName; |
| | | private final String instIdCode; |
| | | |
| | | private volatile WebSocketClient wsClient; |
| | | |
| | | private final ExecutorService executor; |
| | | |
| | | public OkxTradeExecutor(String contract, String marginMode, String accountName) { |
| | | public OkxTradeExecutor(String contract, String marginMode, String accountName, String instIdCode) { |
| | | this.contract = contract; |
| | | this.marginMode = marginMode; |
| | | this.accountName = accountName; |
| | | this.instIdCode = instIdCode; |
| | | this.executor = new ThreadPoolExecutor( |
| | | 1, 1, |
| | | 60L, TimeUnit.SECONDS, |
| | |
| | | |
| | | JSONArray argsArray = new JSONArray(); |
| | | JSONObject args = new JSONObject(); |
| | | args.put("instId", contract); |
| | | args.put("instIdCode", instIdCode); |
| | | args.put("tdMode", marginMode); |
| | | args.put("side", side); |
| | | args.put("posSide", posSide); |
| | |
| | | } |
| | | JSONArray argsArray = new JSONArray(); |
| | | JSONObject args = new JSONObject(); |
| | | args.put("instId", contract); |
| | | args.put("instIdCode", instIdCode); |
| | | args.put("algoOrdType", "conditional"); |
| | | argsArray.add(args); |
| | | |
| | |
| | | |
| | | private JSONObject buildOrderArgs(TradeRequestParam param) { |
| | | JSONObject args = new JSONObject(); |
| | | args.put("instId", param.getInstId()); |
| | | args.put("instIdCode", instIdCode); |
| | | args.put("tdMode", param.getTdMode()); |
| | | args.put("clOrdId", param.getClOrdId()); |
| | | args.put("side", param.getSide()); |
| | |
| | | String connId = OkxWsUtil.getOrderNum("order"); |
| | | JSONObject msg = OkxWsUtil.buildJsonObject(connId, "order", argsArray); |
| | | wsClient.send(msg.toJSONString()); |
| | | log.info("[TradeExec] 发送下单: side={}, sz={}", param.getSide(), param.getSz()); |
| | | } |
| | | |
| | | private void sendBatchOrders(List<TradeRequestParam> params) { |