use of org.knowm.xchange.dto.trade.UserTrades in project XChange by knowm.
the class CoinfloorUserTradesIntegration method fetchUserTradesTest.
@Test
public void fetchUserTradesTest() throws IOException {
final ExchangeSpecification specification = new ExchangeSpecification(CoinfloorExchange.class);
String username = System.getProperty("xchange.coinfloor.username");
String password = System.getProperty("xchange.coinfloor.password");
if (username == null || password == null) {
return;
}
specification.setUserName(username);
specification.setPassword(password);
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(specification);
TradeService service = exchange.getTradeService();
CoinfloorTradeHistoryParams params = (CoinfloorTradeHistoryParams) service.createTradeHistoryParams();
UserTrades trades = service.getTradeHistory(params);
logger.info("{}", trades);
}
use of org.knowm.xchange.dto.trade.UserTrades in project XChange by knowm.
the class CoingiAdapters method adaptTradeHistory.
public static UserTrades adaptTradeHistory(CoingiOrdersList ordersList) {
List<UserTrade> trades = new ArrayList<>();
for (CoingiOrder o : ordersList.getList()) {
final OrderType orderType = o.getType() == 0 ? OrderType.BID : OrderType.ASK;
final CurrencyPair pair = new CurrencyPair(o.getCurrencyPair().get("base").toUpperCase(), o.getCurrencyPair().get("counter").toUpperCase());
UserTrade trade = new UserTrade.Builder().type(orderType).originalAmount(o.getOriginalBaseAmount()).currencyPair(pair).price(o.getPrice()).timestamp(new Date(o.getTimestamp())).id(o.getId()).orderId(o.getId()).feeAmount(BigDecimal.ZERO).build();
trades.add(trade);
}
return new UserTrades(trades, TradeSortType.SortByID);
}
use of org.knowm.xchange.dto.trade.UserTrades in project XChange by knowm.
the class KucoinTradeHistoryDemo method getHistoricalTrades.
private static void getHistoricalTrades(TradeService tradeService) throws IOException {
System.out.println("Requesting trades from the old API (before 18 Feb 2019 UTC+8, no time span limitation)...");
KucoinTradeHistoryParams tradeHistoryParams = (KucoinTradeHistoryParams) tradeService.createTradeHistoryParams();
Date aWhileBack = Date.from(LocalDate.of(2019, 2, 1).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
tradeHistoryParams.setEndTime(aWhileBack);
UserTrades tradeHistory = tradeService.getTradeHistory(tradeHistoryParams);
tradeHistory.getUserTrades().forEach(System.out::println);
}
use of org.knowm.xchange.dto.trade.UserTrades in project XChange by knowm.
the class KucoinTradeHistoryDemo method getRecentTrades.
private static void getRecentTrades(TradeService tradeService) throws IOException {
System.out.println("Requesting trades from the last 8 days (API allows up to 8 days)...");
KucoinTradeHistoryParams tradeHistoryParams = (KucoinTradeHistoryParams) tradeService.createTradeHistoryParams();
UserTrades tradeHistory = tradeService.getTradeHistory(tradeHistoryParams);
tradeHistory.getUserTrades().forEach(System.out::println);
}
use of org.knowm.xchange.dto.trade.UserTrades 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);
}
Aggregations