in java/connectors/polygon-io/src/main/java/com/epam/deltix/data/connectors/polygon/PolygonIoStocksFeed.java [51:107]
protected void processPolygonData(JsonArray array) {
for (int i = 0; i < array.size(); ++i) {
JsonObject obj = array.getObject(i);
String event = obj.getString("ev");
if ("T".equalsIgnoreCase(event)) {
String instrument = obj.getString("sym");
long timestamp = obj.getLong("t");
long price = obj.getDecimal64Required("p");
long size = obj.getDecimal64Required("s");
String ex = String.valueOf(obj.getLong("x"));
String conditions = readConditions(obj.getArray("c"));
processor().onTrade(
instrument, timestamp, price, size, null, ex, conditions
);
if (logger().isDebugEnabled()) {
logger().debug(() ->
"TRADE: " + instrument +
" | t: " + timestamp +
" | p: " + Decimal64Utils.toString(price) +
", s: " + Decimal64Utils.toString(size) +
", ex: " + ex +
", conditions: " + conditions
);
}
} else if ("Q".equalsIgnoreCase(event)) {
String instrument = obj.getString("sym");
long timestamp = obj.getLong("t");
long askPrice = obj.getDecimal64Required("ap");
long askSize = obj.getDecimal64Required("as");
String askEx = String.valueOf(obj.getLong("ax"));
long bidPrice = obj.getDecimal64Required("bp");
long bidSize = obj.getDecimal64Required("bs");
String bidEx = String.valueOf(obj.getLong("bx"));
processor().onL1Snapshot(
instrument, timestamp, bidPrice, bidSize, bidEx, askPrice, askSize, askEx
);
if (logger().isDebugEnabled()) {
logger().debug(() ->
"QUOTE: " + instrument +
" | t: " + timestamp +
" | bidP: " + Decimal64Utils.toString(bidPrice) +
", bidS: " + Decimal64Utils.toString(bidSize) +
", bidEx: " + bidEx +
"| askP: " + Decimal64Utils.toString(askPrice) +
", askS: " + Decimal64Utils.toString(askSize) +
", askEx: " + askEx
);
}
} else if ("status".equalsIgnoreCase(event)) {
processStatusEvent(obj);
}
}
}