
estonlabs.cxtl.exchanges.bullish.api.v2.domain.CreateOrderRequest Maven / Gradle / Ivy
package estonlabs.cxtl.exchanges.bullish.api.v2.domain;
import com.fasterxml.jackson.annotation.*;
import lombok.Getter;
import lombok.ToString;
import java.math.BigDecimal;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder({
"symbol",
"commandType",
"type",
"side",
"quantity",
"price",
"stopPrice",
"timeInForce",
"allowBorrow",
"clientOrderId",
"tradingAccountId"
})
@Getter
@ToString
public class CreateOrderRequest {
@JsonIgnore
private final long creationTime;
@JsonProperty("commandType")
private final String commandType;
@JsonProperty("clientOrderId")
private final String clientOrderId;
@JsonProperty("symbol")
private final String symbol;
@JsonProperty("type")
private OrderType type;
@JsonProperty("side")
private final Side side;
@JsonProperty("price")
private String price;
@JsonProperty("stopPrice")
private String stopPrice;
@JsonProperty("quantity")
private final String quantity;
@JsonProperty("timeInForce")
private Tif timeInForce;
@JsonProperty("allowBorrow")
private boolean allowBorrow;
@JsonProperty("tradingAccountId")
private String tradingAccountId;
public CreateOrderRequest(long creationTime, String clientOrderId, String symbol, Side side, Tif timeInForce,
Double price, double quantity, String tradingAccountId) {
this.creationTime = creationTime;
this.commandType="V3CreateOrder";
this.clientOrderId = clientOrderId;
this.symbol = symbol;
this.side = side;
this.timeInForce = timeInForce;
this.type=price==null?OrderType.MARKET :OrderType.LIMIT;
this.price = price==null?null:getStringFromDouble(price);
this.quantity = getStringFromDouble(quantity);
this.tradingAccountId=tradingAccountId;
}
private String getStringFromDouble(double d){
return BigDecimal.valueOf(d).toPlainString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy