package com.xcong.excoin.modules.okxNewPrice; import java.math.BigDecimal; /** * 单笔挂单的完整参数,封装条件开仓单及止盈单的状态。 * *

定位

* 每个 OkxGridElement 内嵌两个 OkxTraderParam(longTraderParam / shortTraderParam), * 分别记录该价格层级上多仓和空仓的挂单参数。 * *

字段分组

* * * * * * *
类别字段生命周期
开仓准备direction, entryPrice, quantityupdateGridElements() 预填充
止盈预定takeProfitPriceupdateGridElements() 预填充
挂单确认entryOrderPlaced, entryOrderId条件单挂成功后写入
止盈确认takeProfitPlaced, takeProfitOrderId止盈单挂成功后写入
* * @author Administrator */ public class OkxTraderParam { public enum Direction { LONG, SHORT } /** 交易方向 */ private Direction direction; /** 下单数量(合约张数) */ private String quantity; /** 条件开仓触发价 */ private BigDecimal entryPrice; /** 挂单(条件开仓单)订单 ID */ private String entryOrderId; /** 挂单价是否挂成功 */ private boolean entryOrderPlaced; /** 止盈触发价 */ private BigDecimal takeProfitPrice; /** 止盈条件单(算法单)订单 ID(OKX 用 algoId) */ private String takeProfitOrderId; /** 止盈价是否挂成功 */ private boolean takeProfitPlaced; private OkxTraderParam(Builder builder) { this.direction = builder.direction; this.entryPrice = builder.entryPrice; this.takeProfitPrice = builder.takeProfitPrice; this.quantity = builder.quantity; this.takeProfitPlaced = builder.takeProfitPlaced; this.entryOrderPlaced = builder.entryOrderPlaced; this.takeProfitOrderId = builder.takeProfitOrderId; this.entryOrderId = builder.entryOrderId; } public Direction getDirection() { return direction; } public void setDirection(Direction direction) { this.direction = direction; } public BigDecimal getEntryPrice() { return entryPrice; } public void setEntryPrice(BigDecimal entryPrice) { this.entryPrice = entryPrice; } public BigDecimal getTakeProfitPrice() { return takeProfitPrice; } public void setTakeProfitPrice(BigDecimal takeProfitPrice) { this.takeProfitPrice = takeProfitPrice; } public String getQuantity() { return quantity; } public void setQuantity(String quantity) { this.quantity = quantity; } public String getEntryOrderId() { return entryOrderId; } public void setEntryOrderId(String entryOrderId) { this.entryOrderId = entryOrderId; } public boolean isEntryOrderPlaced() { return entryOrderPlaced; } public void setEntryOrderPlaced(boolean entryOrderPlaced) { this.entryOrderPlaced = entryOrderPlaced; } public boolean isTakeProfitPlaced() { return takeProfitPlaced; } public void setTakeProfitPlaced(boolean takeProfitPlaced) { this.takeProfitPlaced = takeProfitPlaced; } public String getTakeProfitOrderId() { return takeProfitOrderId; } public void setTakeProfitOrderId(String takeProfitOrderId) { this.takeProfitOrderId = takeProfitOrderId; } public static Builder builder() { return new Builder(); } public static class Builder { private Direction direction; private BigDecimal entryPrice; private BigDecimal takeProfitPrice; private String quantity = "1"; private boolean takeProfitPlaced = false; private boolean entryOrderPlaced = false; private String takeProfitOrderId; private String entryOrderId; public Builder direction(Direction direction) { this.direction = direction; return this; } public Builder entryPrice(BigDecimal entryPrice) { this.entryPrice = entryPrice; return this; } public Builder takeProfitPrice(BigDecimal takeProfitPrice) { this.takeProfitPrice = takeProfitPrice; return this; } public Builder quantity(String quantity) { this.quantity = quantity; return this; } public Builder takeProfitPlaced(boolean takeProfitPlaced) { this.takeProfitPlaced = takeProfitPlaced; return this; } public Builder entryOrderPlaced(boolean entryOrderPlaced) { this.entryOrderPlaced = entryOrderPlaced; return this; } public Builder takeProfitOrderId(String takeProfitOrderId) { this.takeProfitOrderId = takeProfitOrderId; return this; } public Builder entryOrderId(String entryOrderId) { this.entryOrderId = entryOrderId; return this; } public OkxTraderParam build() { return new OkxTraderParam(this); } } }