| | |
| | | .contract("BTC-USDT-SWAP") |
| | | .leverage("100") |
| | | .marginMode("cross") |
| | | .posMode("long_short_mode") |
| | | .gridRate(new BigDecimal("0.0015")) |
| | | .overallTp(new BigDecimal("5")) |
| | | .maxLoss(new BigDecimal("15")) |
| | |
| | | .unrealizedPnlPriceMode(OkxConfig.PnLPriceMode.LAST_PRICE) |
| | | .isProduction(false) |
| | | .build(); |
| | | |
| | | setupAccount(); |
| | | |
| | | String accountName = "OKX_API"; |
| | | gridTradeService = new OkxGridTradeService(config, accountName); |
| | |
| | | log.info("[管理器] 销毁完成"); |
| | | } |
| | | |
| | | private void setupAccount() { |
| | | log.info("[管理器] 开始配置账户..."); |
| | | OkxRestClient restClient = new OkxRestClient( |
| | | config.getRestBaseUrl(), |
| | | config.getApiKey(), |
| | | config.getSecretKey(), |
| | | config.getPassphrase(), |
| | | !config.isProduction()); |
| | | |
| | | boolean posModeOk = restClient.setPositionMode(config.getPosMode()); |
| | | if (!posModeOk) { |
| | | log.error("[管理器] 设置持仓方式失败,策略可能无法正常运作"); |
| | | } |
| | | |
| | | boolean leverOk = restClient.setLeverage( |
| | | config.getContract(), config.getLeverage(), config.getMarginMode()); |
| | | if (!leverOk) { |
| | | log.error("[管理器] 设置杠杆倍数失败,策略可能无法正常运作"); |
| | | } |
| | | |
| | | log.info("[管理器] 账户配置完成, posMode:{}, leverage:{}, marginMode:{}", |
| | | config.getPosMode(), config.getLeverage(), config.getMarginMode()); |
| | | } |
| | | |
| | | public OkxKlineWebSocketClient getKlineWebSocketClient() { return wsKlineClient; } |
| | | public OkxKlineWebSocketClient getPrivateWebSocketClient() { return wsPrivateClient; } |
| | | public OkxGridTradeService getGridTradeService() { return gridTradeService; } |