Search in sources :

Example 1 with LedgerType

use of org.knowm.xchange.kraken.dto.account.LedgerType in project XChange by knowm.

the class KrakenAccountService method getFundingHistory.

@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
    Date startTime = null;
    Date endTime = null;
    if (params instanceof TradeHistoryParamsTimeSpan) {
        TradeHistoryParamsTimeSpan timeSpanParam = (TradeHistoryParamsTimeSpan) params;
        startTime = timeSpanParam.getStartTime();
        endTime = timeSpanParam.getEndTime();
    }
    Long offset = null;
    if (params instanceof TradeHistoryParamOffset) {
        offset = ((TradeHistoryParamOffset) params).getOffset();
    }
    Currency[] currencies = null;
    if (params instanceof TradeHistoryParamCurrencies) {
        final TradeHistoryParamCurrencies currenciesParam = (TradeHistoryParamCurrencies) params;
        if (currenciesParam.getCurrencies() != null) {
            currencies = currenciesParam.getCurrencies();
        }
    }
    LedgerType ledgerType = null;
    if (params instanceof HistoryParamsFundingType) {
        final FundingRecord.Type type = ((HistoryParamsFundingType) params).getType();
        ledgerType = type == FundingRecord.Type.DEPOSIT ? LedgerType.DEPOSIT : type == FundingRecord.Type.WITHDRAWAL ? LedgerType.WITHDRAWAL : null;
    }
    if (ledgerType == null) {
        Map<String, KrakenLedger> ledgerEntries = getKrakenLedgerInfo(LedgerType.DEPOSIT, startTime, endTime, offset, currencies);
        ledgerEntries.putAll(getKrakenLedgerInfo(LedgerType.WITHDRAWAL, startTime, endTime, offset, currencies));
        return KrakenAdapters.adaptFundingHistory(ledgerEntries);
    } else {
        return KrakenAdapters.adaptFundingHistory(getKrakenLedgerInfo(ledgerType, startTime, endTime, offset, currencies));
    }
}
Also used : DefaultTradeHistoryParamsTimeSpan(org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamsTimeSpan) TradeHistoryParamsTimeSpan(org.knowm.xchange.service.trade.params.TradeHistoryParamsTimeSpan) TradeHistoryParamOffset(org.knowm.xchange.service.trade.params.TradeHistoryParamOffset) KrakenLedger(org.knowm.xchange.kraken.dto.account.KrakenLedger) Date(java.util.Date) LedgerType(org.knowm.xchange.kraken.dto.account.LedgerType) TradeHistoryParamCurrencies(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencies) Currency(org.knowm.xchange.currency.Currency) FundingRecord(org.knowm.xchange.dto.account.FundingRecord) HistoryParamsFundingType(org.knowm.xchange.service.trade.params.HistoryParamsFundingType)

Aggregations

Date (java.util.Date)1 Currency (org.knowm.xchange.currency.Currency)1 FundingRecord (org.knowm.xchange.dto.account.FundingRecord)1 KrakenLedger (org.knowm.xchange.kraken.dto.account.KrakenLedger)1 LedgerType (org.knowm.xchange.kraken.dto.account.LedgerType)1 DefaultTradeHistoryParamsTimeSpan (org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamsTimeSpan)1 HistoryParamsFundingType (org.knowm.xchange.service.trade.params.HistoryParamsFundingType)1 TradeHistoryParamCurrencies (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencies)1 TradeHistoryParamOffset (org.knowm.xchange.service.trade.params.TradeHistoryParamOffset)1 TradeHistoryParamsTimeSpan (org.knowm.xchange.service.trade.params.TradeHistoryParamsTimeSpan)1