| | |
| | | private final String contract; |
| | | private final String leverage; |
| | | private final String marginMode; |
| | | private final String posMode; |
| | | private final BigDecimal gridRate; |
| | | private final BigDecimal overallTp; |
| | | private final BigDecimal maxLoss; |
| | |
| | | private final BigDecimal marginRatioLimit; |
| | | private final BigDecimal contractMultiplier; |
| | | private final PnLPriceMode unrealizedPnlPriceMode; |
| | | private final BigDecimal maxPosSize; |
| | | private BigDecimal step; |
| | | private Long instIdCode; |
| | | |
| | | private OkxConfig(Builder builder) { |
| | | this.apiKey = builder.apiKey; |
| | |
| | | this.contract = builder.contract; |
| | | this.leverage = builder.leverage; |
| | | this.marginMode = builder.marginMode; |
| | | this.posMode = builder.posMode; |
| | | this.gridRate = builder.gridRate; |
| | | this.overallTp = builder.overallTp; |
| | | this.maxLoss = builder.maxLoss; |
| | |
| | | this.marginRatioLimit = builder.marginRatioLimit; |
| | | this.contractMultiplier = builder.contractMultiplier; |
| | | this.unrealizedPnlPriceMode = builder.unrealizedPnlPriceMode; |
| | | this.maxPosSize = builder.maxPosSize; |
| | | } |
| | | |
| | | // ==================== WS 地址 ==================== |
| | |
| | | : "wss://wspap.okx.com:8443/ws/v5/private"; |
| | | } |
| | | |
| | | // ==================== REST 地址 ==================== |
| | | |
| | | public String getRestBaseUrl() { |
| | | return isProduction |
| | | ? "https://www.okx.com" |
| | | : "https://www.okx.com"; |
| | | } |
| | | |
| | | // ==================== 认证信息 ==================== |
| | | |
| | | public String getApiKey() { return apiKey; } |
| | |
| | | // ==================== 持仓配置 ==================== |
| | | |
| | | public String getMarginMode() { return marginMode; } |
| | | public String getPosMode() { return posMode; } |
| | | |
| | | // ==================== 策略参数 ==================== |
| | | |
| | |
| | | public BigDecimal getOverallTp() { return overallTp; } |
| | | public BigDecimal getMaxLoss() { return maxLoss; } |
| | | public String getQuantity() { return quantity; } |
| | | public BigDecimal getMaxPosSize() { return maxPosSize; } |
| | | public int getGridQueueSize() { return gridQueueSize; } |
| | | |
| | | // ==================== 风险控制 ==================== |
| | |
| | | |
| | | public BigDecimal getContractMultiplier() { return contractMultiplier; } |
| | | public PnLPriceMode getUnrealizedPnlPriceMode() { return unrealizedPnlPriceMode; } |
| | | |
| | | public BigDecimal getStep() { return step; } |
| | | public void setStep(BigDecimal step) { this.step = step; } |
| | | |
| | | public Long getInstIdCode() { return instIdCode; } |
| | | public void setInstIdCode(Long instIdCode) { this.instIdCode = instIdCode; } |
| | | |
| | | // ==================== 环境 ==================== |
| | | |
| | |
| | | private String contract = "BTC-USDT-SWAP"; |
| | | private String leverage = "100"; |
| | | private String marginMode = "cross"; |
| | | private String posMode = "long_short_mode"; |
| | | private BigDecimal gridRate = new BigDecimal("0.0035"); |
| | | private BigDecimal overallTp = new BigDecimal("5"); |
| | | private BigDecimal maxLoss = new BigDecimal("15"); |
| | |
| | | private BigDecimal marginRatioLimit = new BigDecimal("0.2"); |
| | | private BigDecimal contractMultiplier = new BigDecimal("1"); |
| | | private PnLPriceMode unrealizedPnlPriceMode = PnLPriceMode.LAST_PRICE; |
| | | private BigDecimal maxPosSize = new BigDecimal("10"); |
| | | |
| | | public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; } |
| | | public Builder secretKey(String secretKey) { this.secretKey = secretKey; return this; } |
| | |
| | | public Builder contract(String contract) { this.contract = contract; return this; } |
| | | public Builder leverage(String leverage) { this.leverage = leverage; return this; } |
| | | public Builder marginMode(String marginMode) { this.marginMode = marginMode; return this; } |
| | | public Builder posMode(String posMode) { this.posMode = posMode; return this; } |
| | | public Builder gridRate(BigDecimal gridRate) { this.gridRate = gridRate; return this; } |
| | | public Builder overallTp(BigDecimal overallTp) { this.overallTp = overallTp; return this; } |
| | | public Builder maxLoss(BigDecimal maxLoss) { this.maxLoss = maxLoss; return this; } |
| | |
| | | public Builder isProduction(boolean isProduction) { this.isProduction = isProduction; return this; } |
| | | public Builder contractMultiplier(BigDecimal contractMultiplier) { this.contractMultiplier = contractMultiplier; return this; } |
| | | public Builder unrealizedPnlPriceMode(PnLPriceMode mode) { this.unrealizedPnlPriceMode = mode; return this; } |
| | | public Builder maxPosSize(BigDecimal maxPosSize) { this.maxPosSize = maxPosSize; return this; } |
| | | |
| | | public OkxConfig build() { |
| | | return new OkxConfig(this); |