Search in sources :

Example 1 with ExmoTradeHistoryParams

use of org.knowm.xchange.exmo.dto.trade.ExmoTradeHistoryParams in project XChange by knowm.

the class ExmoTradeService method getTradeHistory.

@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
    Integer limit = 10000;
    Long offset = 0L;
    List<CurrencyPair> currencyPairs = new ArrayList<>();
    if (params instanceof ExmoTradeHistoryParams) {
        ExmoTradeHistoryParams exmoTradeHistoryParams = (ExmoTradeHistoryParams) params;
        currencyPairs.addAll(exmoTradeHistoryParams.getCurrencyPairs());
    } else if (params instanceof TradeHistoryParamCurrencyPair) {
        TradeHistoryParamCurrencyPair tradeHistoryParamCurrencyPair = (TradeHistoryParamCurrencyPair) params;
        currencyPairs.add(tradeHistoryParamCurrencyPair.getCurrencyPair());
    }
    if (params instanceof TradeHistoryParamLimit) {
        limit = ((TradeHistoryParamLimit) params).getLimit();
    }
    if (params instanceof TradeHistoryParamOffset) {
        offset = ((TradeHistoryParamOffset) params).getOffset();
    }
    List<UserTrade> trades = trades(limit, offset, currencyPairs);
    return new UserTrades(trades, Trades.TradeSortType.SortByTimestamp);
}
Also used : ExmoUserTrades(org.knowm.xchange.exmo.dto.trade.ExmoUserTrades) UserTrades(org.knowm.xchange.dto.trade.UserTrades) TradeHistoryParamOffset(org.knowm.xchange.service.trade.params.TradeHistoryParamOffset) ArrayList(java.util.ArrayList) ExmoTradeHistoryParams(org.knowm.xchange.exmo.dto.trade.ExmoTradeHistoryParams) UserTrade(org.knowm.xchange.dto.trade.UserTrade) TradeHistoryParamLimit(org.knowm.xchange.service.trade.params.TradeHistoryParamLimit) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Aggregations

ArrayList (java.util.ArrayList)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 UserTrade (org.knowm.xchange.dto.trade.UserTrade)1 UserTrades (org.knowm.xchange.dto.trade.UserTrades)1 ExmoTradeHistoryParams (org.knowm.xchange.exmo.dto.trade.ExmoTradeHistoryParams)1 ExmoUserTrades (org.knowm.xchange.exmo.dto.trade.ExmoUserTrades)1 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)1 TradeHistoryParamLimit (org.knowm.xchange.service.trade.params.TradeHistoryParamLimit)1 TradeHistoryParamOffset (org.knowm.xchange.service.trade.params.TradeHistoryParamOffset)1