Search in sources :

Example 1 with BTCMarketsTradeHistoryResponse

use of org.knowm.xchange.btcmarkets.dto.v3.trade.BTCMarketsTradeHistoryResponse in project XChange by knowm.

the class BTCMarketsAdaptersTest method shouldAdaptTradeHistoryResponse.

@Test
public void shouldAdaptTradeHistoryResponse() throws IOException {
    final BTCMarketsTradeHistoryResponse response = parse(BTCMarketsTradeHistoryResponse.class, "v3");
    final UserTrade userTrade = BTCMarketsAdapters.adaptTradeHistory(response);
    assertThat(userTrade.getId()).isEqualTo("36014819");
    assertThat(userTrade.getTimestamp().getTime()).isEqualTo(1561479439000L);
    assertThat(userTrade.getPrice()).isEqualTo("0.67");
    assertThat(userTrade.getOriginalAmount()).isEqualTo("1.50533262");
    assertThat(userTrade.getType()).isEqualTo(Order.OrderType.ASK);
    assertThat(userTrade.getFeeAmount()).isEqualTo("0.00857285");
    assertThat(userTrade.getFeeCurrency()).isEqualTo(Currency.AUD);
    assertThat(userTrade.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_AUD);
}
Also used : BTCMarketsTradeHistoryResponse(org.knowm.xchange.btcmarkets.dto.v3.trade.BTCMarketsTradeHistoryResponse) UserTrade(org.knowm.xchange.dto.trade.UserTrade) Test(org.junit.Test)

Example 2 with BTCMarketsTradeHistoryResponse

use of org.knowm.xchange.btcmarkets.dto.v3.trade.BTCMarketsTradeHistoryResponse in project XChange by knowm.

the class BTCMarketsTradeService method getTradeHistory.

@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
    Integer limit = 200;
    if (params instanceof TradeHistoryParamPaging) {
        limit = ((TradeHistoryParamPaging) params).getPageLength();
    }
    String after = null;
    if (params instanceof TradeHistoryParamsIdSpan) {
        TradeHistoryParamsIdSpan tradeHistoryParamsIdSpan = (TradeHistoryParamsIdSpan) params;
        after = tradeHistoryParamsIdSpan.getStartId();
    }
    String before = null;
    if (params instanceof TradeHistoryParamsIdSpan) {
        TradeHistoryParamsIdSpan tradeHistoryParamsIdSpan = (TradeHistoryParamsIdSpan) params;
        before = tradeHistoryParamsIdSpan.getEndId();
    }
    CurrencyPair cp = null;
    if (params instanceof TradeHistoryParamCurrencyPair) {
        CurrencyPair paramsCp = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
        if (paramsCp != null) {
            cp = paramsCp;
        }
    }
    List<BTCMarketsTradeHistoryResponse> response = getBTCMarketsUserTransactions(cp, before, after, limit);
    return BTCMarketsAdapters.adaptTradeHistory(response);
}
Also used : TradeHistoryParamPaging(org.knowm.xchange.service.trade.params.TradeHistoryParamPaging) TradeHistoryParamsIdSpan(org.knowm.xchange.service.trade.params.TradeHistoryParamsIdSpan) BTCMarketsTradeHistoryResponse(org.knowm.xchange.btcmarkets.dto.v3.trade.BTCMarketsTradeHistoryResponse) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Aggregations

BTCMarketsTradeHistoryResponse (org.knowm.xchange.btcmarkets.dto.v3.trade.BTCMarketsTradeHistoryResponse)2 Test (org.junit.Test)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 UserTrade (org.knowm.xchange.dto.trade.UserTrade)1 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)1 TradeHistoryParamPaging (org.knowm.xchange.service.trade.params.TradeHistoryParamPaging)1 TradeHistoryParamsIdSpan (org.knowm.xchange.service.trade.params.TradeHistoryParamsIdSpan)1 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)1 OpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)1