use of org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair in project XChange by knowm.
the class OkCoinAccountDemo method fundingHistory.
private static void fundingHistory(AccountService accountService) throws IOException {
// Get the funds information
TradeHistoryParams params = accountService.createFundingHistoryParams();
if (params instanceof TradeHistoryParamPaging) {
TradeHistoryParamPaging pagingParams = (TradeHistoryParamPaging) params;
pagingParams.setPageLength(50);
pagingParams.setPageNumber(1);
}
if (params instanceof TradeHistoryParamCurrencyPair) {
((TradeHistoryParamCurrencyPair) params).setCurrencyPair(CurrencyPair.BTC_CNY);
}
final List<FundingRecord> fundingRecords = accountService.getFundingHistory(params);
AccountServiceTestUtil.printFundingHistory(fundingRecords);
}
use of org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair 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.TradeHistoryParamCurrencyPair in project XChange by knowm.
the class BitbayTradeService method getTradeHistory.
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
CurrencyPair currencyPair = null;
if (params instanceof TradeHistoryParamCurrencyPair) {
currencyPair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
}
List<Map> response = getBitbayTransactions(currencyPair);
List<UserTrade> trades = BitbayAdapters.adaptTransactions(response);
return new UserTrades(trades, Trades.TradeSortType.SortByTimestamp);
}
use of org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair 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.TradeHistoryParamCurrencyPair 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