Search in sources :

Example 1 with BiboxFundsCommandBody

use of org.knowm.xchange.bibox.dto.account.BiboxFundsCommandBody 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;
}
Also used : HistoryParamsFundingType(org.knowm.xchange.service.trade.params.HistoryParamsFundingType) Type(org.knowm.xchange.dto.account.FundingRecord.Type) BiboxFundsCommandBody(org.knowm.xchange.bibox.dto.account.BiboxFundsCommandBody) TradeHistoryParamCurrency(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency) Currency(org.knowm.xchange.currency.Currency) FundingRecord(org.knowm.xchange.dto.account.FundingRecord) ArrayList(java.util.ArrayList) HistoryParamsFundingType(org.knowm.xchange.service.trade.params.HistoryParamsFundingType) TradeHistoryParamCurrency(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency)

Aggregations

ArrayList (java.util.ArrayList)1 BiboxFundsCommandBody (org.knowm.xchange.bibox.dto.account.BiboxFundsCommandBody)1 Currency (org.knowm.xchange.currency.Currency)1 FundingRecord (org.knowm.xchange.dto.account.FundingRecord)1 Type (org.knowm.xchange.dto.account.FundingRecord.Type)1 HistoryParamsFundingType (org.knowm.xchange.service.trade.params.HistoryParamsFundingType)1 TradeHistoryParamCurrency (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency)1