in java/connectors/bitmex/src/main/java/com/epam/deltix/data/connectors/bitmex/BitmexFeed.java [167:206]
private void processChanges(
String instrument, QuoteSequenceProcessor quotesListener,
LongToLongHashMap idToPrice, String action, JsonArray changes) {
if (changes == null) {
return;
}
for (int i = 0; i < changes.size(); i++) {
JsonObject change = changes.getObjectRequired(i);
String symbol = change.getString("symbol");
if (!instrument.equalsIgnoreCase(symbol)) {
throw new RuntimeException("Invalid symbol in snapshot: " + symbol);
}
long id = change.getLong("id");
long size = TypeConstants.DECIMAL_NULL;
long price = TypeConstants.DECIMAL_NULL;
if ("insert".equalsIgnoreCase(action)) {
price = change.getDecimal64Required("price");
size = change.getDecimal64Required("size");
idToPrice.put(id, price);
} else if ("delete".equalsIgnoreCase(action)) {
price = idToPrice.remove(id, Long.MIN_VALUE);
if (price == Long.MIN_VALUE) {
throw new RuntimeException("Unknown price with id: " + id);
}
} else if ("update".equalsIgnoreCase(action)) {
price = idToPrice.get(id, Long.MIN_VALUE);
size = change.getDecimal64Required("size");
if (price == Long.MIN_VALUE) {
throw new RuntimeException("Unknown price with id: " + id);
}
}
boolean isOffer = "sell".equalsIgnoreCase(change.getStringRequired("side"));
quotesListener.onQuote(price, size, isOffer);
}
}