use of org.knowm.xchange.service.trade.params.TradeHistoryParamLimit 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);
}
}
use of org.knowm.xchange.service.trade.params.TradeHistoryParamLimit in project XChange by knowm.
the class BitbayTradeService method getTradeHistory.
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
final BitbayUserTradesQuery query = new BitbayUserTradesQuery();
if (params instanceof TradeHistoryParamNextPageCursor) {
query.setNextPageCursor(((TradeHistoryParamNextPageCursor) params).getNextPageCursor());
}
if (params instanceof TradeHistoryParamLimit) {
Integer limit = ((TradeHistoryParamLimit) params).getLimit();
query.setLimit(limit != null ? limit.toString() : null);
}
if (params instanceof TradeHistoryParamMultiCurrencyPair) {
final Collection<CurrencyPair> currencyPairs = ((TradeHistoryParamMultiCurrencyPair) params).getCurrencyPairs();
query.setMarkets(currencyPairs.stream().map(BitbayAdapters::adaptCurrencyPair).collect(Collectors.toList()));
}
final BitbayUserTrades response = getBitbayTransactions(query);
return BitbayAdapters.adaptUserTrades(response);
}
use of org.knowm.xchange.service.trade.params.TradeHistoryParamLimit in project XChange by knowm.
the class BitbayAccountService method getFundingHistory.
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
Currency currency = null;
if (params instanceof TradeHistoryParamCurrency) {
TradeHistoryParamCurrency tradeHistoryParamCurrency = (TradeHistoryParamCurrency) params;
currency = tradeHistoryParamCurrency.getCurrency();
}
Integer limit = 1000;
if (params instanceof TradeHistoryParamLimit) {
limit = ((TradeHistoryParamLimit) params).getLimit();
}
return history(currency, limit);
}
use of org.knowm.xchange.service.trade.params.TradeHistoryParamLimit in project XChange by knowm.
the class CryptopiaTradeService method getTradeHistory.
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
try {
CurrencyPair currencyPair = null;
Integer limit = 100;
if (params instanceof TradeHistoryParamCurrencyPair) {
currencyPair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
}
if (params instanceof TradeHistoryParamLimit) {
limit = ((TradeHistoryParamLimit) params).getLimit();
}
return new UserTrades(tradeHistory(currencyPair, limit), Trades.TradeSortType.SortByTimestamp);
} catch (CryptopiaException e) {
throw CryptopiaErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.service.trade.params.TradeHistoryParamLimit in project XChange by knowm.
the class YoBitTradeService method getTradeHistory.
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
Integer count = 1000;
if (params instanceof TradeHistoryParamLimit) {
count = ((TradeHistoryParamLimit) params).getLimit();
}
Long offset = 0L;
if (params instanceof TradeHistoryParamOffset) {
offset = ((TradeHistoryParamOffset) params).getOffset();
}
String market = null;
if (params instanceof TradeHistoryParamCurrencyPair) {
CurrencyPair currencyPair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
market = YoBitAdapters.adaptCcyPairToUrlFormat(currencyPair);
}
Long fromTransactionId = null;
Long endTransactionId = null;
if (params instanceof TradeHistoryParamsIdSpan) {
TradeHistoryParamsIdSpan tradeHistoryParamsIdSpan = (TradeHistoryParamsIdSpan) params;
String startId = tradeHistoryParamsIdSpan.getStartId();
if (startId != null)
fromTransactionId = Long.valueOf(startId);
String endId = tradeHistoryParamsIdSpan.getEndId();
if (endId != null)
endTransactionId = Long.valueOf(endId);
}
String order = "DESC";
if (params instanceof TradeHistoryParamsSorted) {
order = ((TradeHistoryParamsSorted) params).getOrder().equals(TradeHistoryParamsSorted.Order.desc) ? "DESC" : "ASC";
}
Long fromTimestamp = null;
Long toTimestamp = null;
if (params instanceof TradeHistoryParamsTimeSpan) {
TradeHistoryParamsTimeSpan tradeHistoryParamsTimeSpan = (TradeHistoryParamsTimeSpan) params;
Date startTime = tradeHistoryParamsTimeSpan.getStartTime();
if (startTime != null)
fromTimestamp = DateUtils.toUnixTimeNullSafe(startTime);
Date endTime = tradeHistoryParamsTimeSpan.getEndTime();
if (endTime != null)
toTimestamp = DateUtils.toUnixTimeNullSafe(endTime);
}
BaseYoBitResponse response = tradeHistory(count, offset, market, fromTransactionId, endTransactionId, order, fromTimestamp, toTimestamp);
List<UserTrade> trades = new ArrayList<>();
if (response.returnData != null) {
for (Object key : response.returnData.keySet()) {
Map tradeData = (Map) response.returnData.get(key);
trades.add(YoBitAdapters.adaptUserTrade(key, tradeData));
}
}
return new UserTrades(trades, Trades.TradeSortType.SortByTimestamp);
}
Aggregations