use of org.knowm.xchange.therock.dto.trade.TheRockTransaction in project XChange by knowm.
the class TheRockAccountService method getFundingHistory.
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
Currency currency = null;
Date after = null;
Date before = null;
FundingRecord.Type type = null;
if (params instanceof TradeHistoryParamCurrency) {
TradeHistoryParamCurrency tradeHistoryParamCurrency = (TradeHistoryParamCurrency) params;
currency = tradeHistoryParamCurrency.getCurrency();
}
if (params instanceof TradeHistoryParamsTimeSpan) {
TradeHistoryParamsTimeSpan tradeHistoryParamsTimeSpan = (TradeHistoryParamsTimeSpan) params;
after = tradeHistoryParamsTimeSpan.getStartTime();
before = tradeHistoryParamsTimeSpan.getEndTime();
}
if (params instanceof HistoryParamsFundingType) {
HistoryParamsFundingType historyParamsFundingType = (HistoryParamsFundingType) params;
type = historyParamsFundingType.getType();
}
List<FundingRecord> all = new ArrayList<>();
if (type == null || type == FundingRecord.Type.DEPOSIT) {
int page = 1;
while (true) {
TheRockTransactions txns = deposits(currency, after, before, page++);
if (txns.getTransactions().length == 0)
break;
for (TheRockTransaction txn : txns.getTransactions()) {
all.add(adapt(txn, FundingRecord.Type.DEPOSIT));
}
}
}
if (type == null || type == FundingRecord.Type.WITHDRAWAL) {
int page = 1;
while (true) {
TheRockTransactions txns = withdrawls(currency, after, before, page++);
if (txns.getTransactions().length == 0)
break;
for (TheRockTransaction txn : txns.getTransactions()) {
all.add(adapt(txn, FundingRecord.Type.WITHDRAWAL));
}
}
}
return all;
}
Aggregations