use of org.knowm.xchange.lakebtc.dto.trade.LakeBTCTradeResponse in project XChange by knowm.
the class LakeBTCTradeHistoryDemo method raw.
private static void raw(Exchange lakeBtcExchange) throws IOException {
LakeBTCTradeServiceRaw tradeService = (LakeBTCTradeServiceRaw) lakeBtcExchange.getTradeService();
// Get the trade history
LakeBTCTradeResponse[] trades = tradeService.getLakeBTCTradeHistory(0);
System.out.println(Arrays.toString(trades));
}
use of org.knowm.xchange.lakebtc.dto.trade.LakeBTCTradeResponse in project XChange by knowm.
the class LakeBTCAdapters method adaptTrades.
/**
* Adapts a Transaction[] to a Trades Object
*
* @param transactions The LakeBtc transactions
* @param currencyPair (e.g. BTC/USD)
* @return The XChange Trades
*/
public static Trades adaptTrades(LakeBTCTradeResponse[] transactions, CurrencyPair currencyPair) {
List<Trade> trades = new ArrayList<>();
long lastTradeId = 0;
for (LakeBTCTradeResponse trade : transactions) {
final OrderType orderType = trade.getType().startsWith("buy") ? OrderType.BID : OrderType.ASK;
trades.add(new Trade.Builder().type(orderType).originalAmount(trade.getAmount()).currencyPair(currencyPair).price(trade.getTotal()).timestamp(DateUtils.fromMillisUtc(trade.getAt() * 1000L)).id(trade.getId()).build());
}
return new Trades(trades, lastTradeId, Trades.TradeSortType.SortByTimestamp);
}
use of org.knowm.xchange.lakebtc.dto.trade.LakeBTCTradeResponse in project XChange by knowm.
the class LakeBTCAdapters method adaptTradeHistory.
/**
* Adapt the user's trades
*
* @param transactions
* @return
*/
public static UserTrades adaptTradeHistory(LakeBTCTradeResponse[] transactions) {
List<UserTrade> trades = new ArrayList<>();
long lastTradeId = 0;
for (LakeBTCTradeResponse trade : transactions) {
final OrderType orderType = trade.getType().startsWith("buy") ? OrderType.BID : OrderType.ASK;
BigDecimal originalAmount = trade.getAmount();
BigDecimal price = trade.getTotal().abs();
Date timestamp = DateUtils.fromMillisUtc(trade.getAt() * 1000L);
final String tradeId = trade.getId();
final CurrencyPair currencyPair = CurrencyPair.BTC_CNY;
UserTrade userTrade = new UserTrade.Builder().type(orderType).originalAmount(originalAmount).currencyPair(currencyPair).price(price).timestamp(timestamp).feeCurrency(Currency.getInstance(currencyPair.counter.getCurrencyCode())).build();
trades.add(userTrade);
}
return new UserTrades(trades, lastTradeId, Trades.TradeSortType.SortByTimestamp);
}
Aggregations