use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTrade in project XChange by knowm.
the class BitfinexAdapters method adaptTrades.
public static Trades adaptTrades(BitfinexTrade[] trades, CurrencyPair currencyPair) {
List<Trade> tradesList = new ArrayList<>(trades.length);
long lastTradeId = 0;
for (BitfinexTrade trade : trades) {
long tradeId = trade.getTradeId();
if (tradeId > lastTradeId) {
lastTradeId = tradeId;
}
tradesList.add(adaptTrade(trade, currencyPair));
}
return new Trades(tradesList, lastTradeId, TradeSortType.SortByID);
}
use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTrade in project XChange by knowm.
the class BitfinexAdapters method adaptTrade.
public static Trade adaptTrade(BitfinexTrade trade, CurrencyPair currencyPair) {
OrderType orderType = trade.getType().equals("buy") ? OrderType.BID : OrderType.ASK;
BigDecimal amount = trade.getAmount();
BigDecimal price = trade.getPrice();
Date date = // Bitfinex uses Unix timestamps
DateUtils.fromMillisUtc(trade.getTimestamp() * 1000L);
final String tradeId = String.valueOf(trade.getTradeId());
return new Trade.Builder().type(orderType).originalAmount(amount).currencyPair(currencyPair).price(price).timestamp(date).id(tradeId).build();
}
Aggregations