Search in sources :

Example 1 with LatokenUserTrades

use of org.knowm.xchange.latoken.dto.trade.LatokenUserTrades in project XChange by knowm.

the class LatokenTradeService method getTradeHistory.

@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
    if (params instanceof TradeHistoryParamCurrencyPair == false) {
        throw new ExchangeException("CurrencyPair must be provided to get user trades.");
    }
    TradeHistoryParamCurrencyPair pairParams = (TradeHistoryParamCurrencyPair) params;
    CurrencyPair pair = pairParams.getCurrencyPair();
    if (pair == null) {
        throw new ExchangeException("CurrencyPair must be provided to get user trades.");
    }
    // Limit is an optional parameter
    Integer limit = null;
    if (params instanceof TradeHistoryParamLimit) {
        TradeHistoryParamLimit limitParams = (TradeHistoryParamLimit) params;
        limit = limitParams.getLimit();
    }
    try {
        LatokenUserTrades latokenTrades = getLatokenUserTrades(pair, limit);
        return LatokenAdapters.adaptUserTrades(this.exchange, latokenTrades);
    } catch (LatokenException e) {
        throw LatokenErrorAdapter.adapt(e);
    }
}
Also used : LatokenException(org.knowm.xchange.latoken.dto.LatokenException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) TradeHistoryParamLimit(org.knowm.xchange.service.trade.params.TradeHistoryParamLimit) LatokenUserTrades(org.knowm.xchange.latoken.dto.trade.LatokenUserTrades) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Example 2 with LatokenUserTrades

use of org.knowm.xchange.latoken.dto.trade.LatokenUserTrades in project XChange by knowm.

the class LatokenAdapters method adaptUserTrades.

public static UserTrades adaptUserTrades(Exchange exchange, LatokenUserTrades latokenUserTrades) {
    CurrencyPair pair = adaptCurrencyPair(exchange, latokenUserTrades.getSymbol());
    List<UserTrade> trades = latokenUserTrades.getTrades().stream().map(latokenUserTrade -> adaptUserTrade(latokenUserTrade, pair)).collect(Collectors.toList());
    return new UserTrades(trades, Trades.TradeSortType.SortByTimestamp);
}
Also used : LatokenOrderbook(org.knowm.xchange.latoken.dto.marketdata.LatokenOrderbook) OrderType(org.knowm.xchange.dto.Order.OrderType) LatokenBalance(org.knowm.xchange.latoken.dto.account.LatokenBalance) LatokenUserTrade(org.knowm.xchange.latoken.dto.trade.LatokenUserTrade) Exchange(org.knowm.xchange.Exchange) OrderBook(org.knowm.xchange.dto.marketdata.OrderBook) Balance(org.knowm.xchange.dto.account.Balance) TradeSortType(org.knowm.xchange.dto.marketdata.Trades.TradeSortType) BigDecimal(java.math.BigDecimal) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) LatokenCurrency(org.knowm.xchange.latoken.dto.exchangeinfo.LatokenCurrency) LatokenTrades(org.knowm.xchange.latoken.dto.marketdata.LatokenTrades) LatokenPair(org.knowm.xchange.latoken.dto.exchangeinfo.LatokenPair) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) RoundingMode(java.math.RoundingMode) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OrderStatus(org.knowm.xchange.dto.Order.OrderStatus) Ticker(org.knowm.xchange.dto.marketdata.Ticker) LatokenOrder(org.knowm.xchange.latoken.dto.trade.LatokenOrder) LatokenOrderSide(org.knowm.xchange.latoken.dto.trade.LatokenOrderSide) UserTrades(org.knowm.xchange.dto.trade.UserTrades) UserTrade(org.knowm.xchange.dto.trade.UserTrade) LatokenOrderStatus(org.knowm.xchange.latoken.dto.trade.LatokenOrderStatus) LatokenTicker(org.knowm.xchange.latoken.dto.marketdata.LatokenTicker) Collectors(java.util.stream.Collectors) Trades(org.knowm.xchange.dto.marketdata.Trades) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) LatokenTrade(org.knowm.xchange.latoken.dto.marketdata.LatokenTrade) List(java.util.List) Currency(org.knowm.xchange.currency.Currency) Optional(java.util.Optional) Trade(org.knowm.xchange.dto.marketdata.Trade) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) LatokenUserTrades(org.knowm.xchange.latoken.dto.trade.LatokenUserTrades) UserTrades(org.knowm.xchange.dto.trade.UserTrades) LatokenUserTrades(org.knowm.xchange.latoken.dto.trade.LatokenUserTrades) LatokenUserTrade(org.knowm.xchange.latoken.dto.trade.LatokenUserTrade) UserTrade(org.knowm.xchange.dto.trade.UserTrade) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

CurrencyPair (org.knowm.xchange.currency.CurrencyPair)2 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)2 LatokenUserTrades (org.knowm.xchange.latoken.dto.trade.LatokenUserTrades)2 BigDecimal (java.math.BigDecimal)1 RoundingMode (java.math.RoundingMode)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Exchange (org.knowm.xchange.Exchange)1 Currency (org.knowm.xchange.currency.Currency)1 OrderStatus (org.knowm.xchange.dto.Order.OrderStatus)1 OrderType (org.knowm.xchange.dto.Order.OrderType)1 Balance (org.knowm.xchange.dto.account.Balance)1 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)1 Ticker (org.knowm.xchange.dto.marketdata.Ticker)1 Trade (org.knowm.xchange.dto.marketdata.Trade)1 Trades (org.knowm.xchange.dto.marketdata.Trades)1 TradeSortType (org.knowm.xchange.dto.marketdata.Trades.TradeSortType)1 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1