use of info.bitrich.xchangestream.coinmate.v2.dto.CoinmateWebsocketOpenOrder in project XChange by knowm.
the class CoinmateStreamingTradeService method getOrderChanges.
@Override
public Observable<Order> getOrderChanges(CurrencyPair currencyPair, Object... args) {
String channelName = "private-open_orders-" + coinmateStreamingService.getUserId() + "-" + CoinmateStreamingAdapter.getChannelPostfix(currencyPair);
ObjectReader reader = StreamingObjectMapperHelper.getObjectMapper().readerFor(CoinmateWebsocketOpenOrder.class);
return coinmateStreamingService.subscribeChannel(channelName, true).map((message) -> {
JsonNode payload = message.get("payload");
List<CoinmateWebsocketOpenOrder> websocketOpenOrders;
if (payload.isArray()) {
websocketOpenOrders = Arrays.asList(reader.readValue(payload, CoinmateWebsocketOpenOrder[].class));
} else {
websocketOpenOrders = Collections.singletonList(reader.readValue(payload, CoinmateWebsocketOpenOrder.class));
}
return CoinmateStreamingAdapter.adaptWebsocketOpenOrders(websocketOpenOrders, currencyPair);
}).concatMapIterable(OpenOrders::getAllOpenOrders);
}
Aggregations