Search in sources :

Example 1 with HitbtcOwnTrade

use of org.knowm.xchange.hitbtc.v2.dto.HitbtcOwnTrade in project XChange by knowm.

the class HitbtcAdapters method adaptTradeHistory.

public static UserTrades adaptTradeHistory(List<HitbtcOwnTrade> tradeHistoryRaw) {
    List<UserTrade> trades = new ArrayList<>(tradeHistoryRaw.size());
    for (HitbtcOwnTrade hitbtcOwnTrade : tradeHistoryRaw) {
        OrderType type = adaptOrderType(hitbtcOwnTrade.getSide().getValue());
        CurrencyPair pair = adaptSymbol(hitbtcOwnTrade.symbol);
        BigDecimal originalAmount = hitbtcOwnTrade.getQuantity();
        Date timestamp = hitbtcOwnTrade.getTimestamp();
        String id = Long.toString(hitbtcOwnTrade.getId());
        String orderId = String.valueOf(hitbtcOwnTrade.getOrderId());
        String clientOrderId = hitbtcOwnTrade.getClientOrderId();
        UserTrade trade = new HitbtcUserTrade(type, originalAmount, pair, hitbtcOwnTrade.getPrice(), timestamp, id, orderId, hitbtcOwnTrade.getFee(), pair.counter, clientOrderId);
        trades.add(trade);
    }
    return new UserTrades(trades, Trades.TradeSortType.SortByTimestamp);
}
Also used : UserTrades(org.knowm.xchange.dto.trade.UserTrades) OrderType(org.knowm.xchange.dto.Order.OrderType) HitbtcUserTrade(org.knowm.xchange.hitbtc.v2.dto.HitbtcUserTrade) ArrayList(java.util.ArrayList) HitbtcOwnTrade(org.knowm.xchange.hitbtc.v2.dto.HitbtcOwnTrade) HitbtcUserTrade(org.knowm.xchange.hitbtc.v2.dto.HitbtcUserTrade) UserTrade(org.knowm.xchange.dto.trade.UserTrade) BigDecimal(java.math.BigDecimal) Date(java.util.Date) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 2 with HitbtcOwnTrade

use of org.knowm.xchange.hitbtc.v2.dto.HitbtcOwnTrade in project XChange by knowm.

the class HitbtcTradeService method getTradeHistory.

/**
 * Required parameters: {@link TradeHistoryParamPaging} {@link TradeHistoryParamCurrencyPair}
 */
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
    Integer limit = 1000;
    long offset = 0;
    if (params instanceof TradeHistoryParamLimit) {
        limit = ((TradeHistoryParamLimit) params).getLimit();
    }
    if (params instanceof TradeHistoryParamOffset) {
        TradeHistoryParamOffset tradeHistoryParamOffset = (TradeHistoryParamOffset) params;
        offset = tradeHistoryParamOffset.getOffset();
    }
    String symbol = null;
    if (params instanceof TradeHistoryParamCurrencyPair) {
        CurrencyPair pair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
        symbol = HitbtcAdapters.adaptCurrencyPair(pair);
    }
    List<HitbtcOwnTrade> tradeHistoryRaw = getTradeHistoryRaw(symbol, limit, offset);
    return HitbtcAdapters.adaptTradeHistory(tradeHistoryRaw);
}
Also used : TradeHistoryParamOffset(org.knowm.xchange.service.trade.params.TradeHistoryParamOffset) HitbtcOwnTrade(org.knowm.xchange.hitbtc.v2.dto.HitbtcOwnTrade) TradeHistoryParamLimit(org.knowm.xchange.service.trade.params.TradeHistoryParamLimit) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Aggregations

CurrencyPair (org.knowm.xchange.currency.CurrencyPair)2 HitbtcOwnTrade (org.knowm.xchange.hitbtc.v2.dto.HitbtcOwnTrade)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 OrderType (org.knowm.xchange.dto.Order.OrderType)1 UserTrade (org.knowm.xchange.dto.trade.UserTrade)1 UserTrades (org.knowm.xchange.dto.trade.UserTrades)1 HitbtcUserTrade (org.knowm.xchange.hitbtc.v2.dto.HitbtcUserTrade)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 OrderQueryParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair)1