use of org.knowm.xchange.dto.account.FundingRecord.Type in project XChange by knowm.
the class BiboxAccountService method getFundingHistory.
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) {
if (!(params instanceof TradeHistoryParamCurrency)) {
throw new RuntimeException("You must provide the currency for funding history @ Bibox.");
}
Currency c = ((TradeHistoryParamCurrency) params).getCurrency();
if (c == null) {
throw new RuntimeException("You must provide the currency for funding history @ Bibox.");
}
boolean deposits = false;
boolean withdrawals = false;
if (params instanceof HistoryParamsFundingType) {
HistoryParamsFundingType typeParams = (HistoryParamsFundingType) params;
Type type = typeParams.getType();
deposits = type == null || type == Type.DEPOSIT;
withdrawals = type == null || type == Type.WITHDRAWAL;
}
BiboxFundsCommandBody body = new BiboxFundsCommandBody(c.getCurrencyCode());
ArrayList<FundingRecord> result = new ArrayList<>();
if (deposits) {
requestBiboxDeposits(body).getItems().forEach(d -> result.add(BiboxAdapters.adaptDeposit(d)));
}
if (withdrawals) {
requestBiboxWithdrawals(body).getItems().forEach(d -> result.add(BiboxAdapters.adaptDeposit(d)));
}
return result;
}
use of org.knowm.xchange.dto.account.FundingRecord.Type in project XChange by knowm.
the class OkCoinAccountService method getFundingHistory.
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
String symbol = null;
if (params instanceof TradeHistoryParamCurrency && ((TradeHistoryParamCurrency) params).getCurrency() != null) {
symbol = OkCoinAdapters.adaptCurrencyToAccountRecordPair(((TradeHistoryParamCurrency) params).getCurrency());
}
if (symbol == null) {
throw new ExchangeException("Symbol must be supplied");
}
Integer pageLength = 50;
Integer pageNumber = null;
if (params instanceof TradeHistoryParamPaging) {
TradeHistoryParamPaging pagingParams = (TradeHistoryParamPaging) params;
if (pagingParams.getPageLength() != null) {
pageLength = pagingParams.getPageLength();
if (pageLength > 50) {
pageLength = 50;
}
}
pageNumber = pagingParams.getPageNumber() != null ? pagingParams.getPageNumber() : 1;
}
FundingRecord.Type type = null;
if (params instanceof HistoryParamsFundingType) {
type = ((HistoryParamsFundingType) params).getType();
}
List<FundingRecord> result = new ArrayList<>();
if (type == null || type == Type.DEPOSIT) {
final OkCoinAccountRecords depositRecord = getAccountRecords(symbol, "0", String.valueOf(pageNumber), String.valueOf(pageLength));
result.addAll(OkCoinAdapters.adaptFundingHistory(depositRecord, Type.DEPOSIT));
}
if (type == null || type == Type.WITHDRAWAL) {
final OkCoinAccountRecords withdrawalRecord = getAccountRecords(symbol, "1", String.valueOf(pageNumber), String.valueOf(pageLength));
result.addAll(OkCoinAdapters.adaptFundingHistory(withdrawalRecord, Type.WITHDRAWAL));
}
return result;
}
Aggregations