
estonlabs.cxtl.exchanges.b2c2.v1.domain.Instrument Maven / Gradle / Ivy
package estonlabs.cxtl.exchanges.b2c2.v1.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import estonlabs.cxtl.exchanges.a.specification.domain.AssetClass;
import estonlabs.cxtl.exchanges.a.specification.domain.Ticker;
import lombok.Data;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Instrument implements Ticker {
protected static final String[] NULL_COMPONENTS = {null, null};
@JsonProperty("name")
private String symbol;
@JsonProperty("underlier")
private String underlier;
@JsonProperty("type")
private AssetClass type;
@JsonProperty("is_tradable")
private boolean isTradable;
@JsonProperty("quantity_precision")
private double quantityPrecision;
@JsonProperty("max_quantity_per_trade")
private double maxQuantityPerTrade;
@JsonProperty("min_quantity_per_trade")
private double minQuantityPerTrade;
@JsonProperty("price_significant_digits")
private int priceSignificantDigits;
private String[] components = null;
public String[] getComponents() {
if(components == null){
if(underlier == null){
return NULL_COMPONENTS;
}
String suffix = underlier.endsWith("USD") ? "USD" : underlier.endsWith("UST") ? "UST" : null;
if (suffix == null) {
return NULL_COMPONENTS;
}
int lastIndex = underlier.lastIndexOf(suffix);
String prefix = underlier.substring(0, lastIndex);
components = new String[]{prefix, suffix};
}
return components;
}
@Override
public String getBaseAsset() {
return getComponents()[0];
}
@Override
public String getQuoteAsset() {
return getComponents()[1];
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy