Search in sources :

Example 1 with CoinmateWebSocketUserTrade

use of info.bitrich.xchangestream.coinmate.v2.dto.CoinmateWebSocketUserTrade in project XChange by knowm.

the class CoinmateStreamingTradeService method getUserTrades.

@Override
public Observable<UserTrade> getUserTrades(CurrencyPair currencyPair, Object... args) {
    String channelName = "private-user-trades-" + coinmateStreamingService.getUserId() + "-" + CoinmateStreamingAdapter.getChannelPostfix(currencyPair);
    ObjectReader reader = StreamingObjectMapperHelper.getObjectMapper().readerFor(new TypeReference<List<CoinmateWebSocketUserTrade>>() {
    });
    return coinmateStreamingService.subscribeChannel(channelName, true).map((message) -> {
        List<CoinmateWebSocketUserTrade> webSocketUserTrades = reader.readValue(message.get("payload"));
        return CoinmateStreamingAdapter.adaptWebSocketUserTrades(webSocketUserTrades, currencyPair);
    }).concatMapIterable(UserTrades::getUserTrades);
}
Also used : Arrays(java.util.Arrays) CoinmateWebsocketOpenOrder(info.bitrich.xchangestream.coinmate.v2.dto.CoinmateWebsocketOpenOrder) UserTrades(org.knowm.xchange.dto.trade.UserTrades) UserTrade(org.knowm.xchange.dto.trade.UserTrade) StreamingObjectMapperHelper(info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) CoinmateWebSocketUserTrade(info.bitrich.xchangestream.coinmate.v2.dto.CoinmateWebSocketUserTrade) Order(org.knowm.xchange.dto.Order) List(java.util.List) JsonNode(com.fasterxml.jackson.databind.JsonNode) Observable(io.reactivex.Observable) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) TypeReference(com.fasterxml.jackson.core.type.TypeReference) StreamingTradeService(info.bitrich.xchangestream.core.StreamingTradeService) Collections(java.util.Collections) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) UserTrades(org.knowm.xchange.dto.trade.UserTrades) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) List(java.util.List)

Aggregations

TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 CoinmateWebSocketUserTrade (info.bitrich.xchangestream.coinmate.v2.dto.CoinmateWebSocketUserTrade)1 CoinmateWebsocketOpenOrder (info.bitrich.xchangestream.coinmate.v2.dto.CoinmateWebsocketOpenOrder)1 StreamingTradeService (info.bitrich.xchangestream.core.StreamingTradeService)1 StreamingObjectMapperHelper (info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper)1 Observable (io.reactivex.Observable)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 Order (org.knowm.xchange.dto.Order)1 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)1 UserTrade (org.knowm.xchange.dto.trade.UserTrade)1 UserTrades (org.knowm.xchange.dto.trade.UserTrades)1