org.knowm.xchange.bitmex.dto.trade.BitmexOrderFlags Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xchange-bitmex Show documentation
Show all versions of xchange-bitmex Show documentation
XChange implementations for the BitMex Exchange.
package org.knowm.xchange.bitmex.dto.trade;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import java.io.IOException;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.knowm.xchange.dto.Order.IOrderFlags;
public enum BitmexOrderFlags implements IOrderFlags {
FCIB, // prefer fee in base currency
FCIQ, // prefer fee in quote currency
NOMPP, // no market price protection
POST, // for market maker orders
VIQC; // volume in quote currency
private static final Map fromString = new HashMap<>();
static {
for (BitmexOrderFlags orderFlag : values()) fromString.put(orderFlag.toString(), orderFlag);
}
public static BitmexOrderFlags fromString(String orderTypeString) {
return fromString.get(orderTypeString.toLowerCase());
}
@Override
public String toString() {
return super.toString().toLowerCase();
}
static class BitmexOrderFlagsDeserializer extends JsonDeserializer> {
@Override
public Set deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
String orderFlagsString = node.textValue();
Set orderFlags = EnumSet.noneOf(BitmexOrderFlags.class);
if (!orderFlagsString.isEmpty()) {
for (String orderFlag : orderFlagsString.split(",")) orderFlags.add(fromString(orderFlag));
}
return orderFlags;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy