Search in sources :

Example 1 with IndependentReserveAdapters

use of org.knowm.xchange.independentreserve.IndependentReserveAdapters in project XChange by knowm.

the class IndependentReserveAccountService method getFundingHistory.

@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
    if (!(params instanceof IndependentReserveTradeHistoryParams)) {
        throw new IllegalArgumentException("Invalid TradeHistoryParams used as argument of getFundingHistory");
    }
    IndependentReserveTradeHistoryParams historyParams = (IndependentReserveTradeHistoryParams) params;
    final IndependentReserveBalance bal = getIndependentReserveBalance();
    final Currency currency = historyParams.getCurrency();
    return bal.getIndependentReserveAccounts().stream().filter(acc -> currency == null || currency.getCurrencyCode().equalsIgnoreCase(acc.getCurrencyCode())).map(acc -> {
        try {
            return getTransactions(acc.getAccountGuid(), historyParams.startTime, historyParams.endTime, historyParams.transactionTypes, historyParams.getPageNumber(), historyParams.getPageLength()).getIndependentReserveTranasactions().stream().map(IndependentReserveAdapters::adaptTransaction);
        } catch (IndependentReserveHttpStatusException | IOException e) {
            throw new ExchangeException(e);
        }
    }).flatMap(Function.identity()).collect(Collectors.toList());
}
Also used : IndependentReserveTransaction(org.knowm.xchange.independentreserve.dto.trade.IndependentReserveTransaction) AccountService(org.knowm.xchange.service.account.AccountService) TradeHistoryParams(org.knowm.xchange.service.trade.params.TradeHistoryParams) Date(java.util.Date) TradeHistoryParamCurrency(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency) IndependentReserveHttpStatusException(org.knowm.xchange.independentreserve.dto.IndependentReserveHttpStatusException) Exchange(org.knowm.xchange.Exchange) FundingRecord(org.knowm.xchange.dto.account.FundingRecord) Function(java.util.function.Function) BigDecimal(java.math.BigDecimal) DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) MoneroWithdrawFundsParams(org.knowm.xchange.service.trade.params.MoneroWithdrawFundsParams) Map(java.util.Map) WithdrawFundsParams(org.knowm.xchange.service.trade.params.WithdrawFundsParams) IndependentReserveAdapters(org.knowm.xchange.independentreserve.IndependentReserveAdapters) AccountInfo(org.knowm.xchange.dto.account.AccountInfo) Fee(org.knowm.xchange.dto.account.Fee) IOException(java.io.IOException) DefaultTradeHistoryParamPaging(org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamPaging) Collectors(java.util.stream.Collectors) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams) List(java.util.List) Currency(org.knowm.xchange.currency.Currency) IndependentReserveBalance(org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance) TradeHistoryParamsTimeSpan(org.knowm.xchange.service.trade.params.TradeHistoryParamsTimeSpan) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) IndependentReserveHttpStatusException(org.knowm.xchange.independentreserve.dto.IndependentReserveHttpStatusException) TradeHistoryParamCurrency(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency) Currency(org.knowm.xchange.currency.Currency) IndependentReserveAdapters(org.knowm.xchange.independentreserve.IndependentReserveAdapters) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) IOException(java.io.IOException) IndependentReserveBalance(org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance)

Aggregations

IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Exchange (org.knowm.xchange.Exchange)1 Currency (org.knowm.xchange.currency.Currency)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 AccountInfo (org.knowm.xchange.dto.account.AccountInfo)1 Fee (org.knowm.xchange.dto.account.Fee)1 FundingRecord (org.knowm.xchange.dto.account.FundingRecord)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1 IndependentReserveAdapters (org.knowm.xchange.independentreserve.IndependentReserveAdapters)1 IndependentReserveHttpStatusException (org.knowm.xchange.independentreserve.dto.IndependentReserveHttpStatusException)1 IndependentReserveBalance (org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance)1 IndependentReserveTransaction (org.knowm.xchange.independentreserve.dto.trade.IndependentReserveTransaction)1 AccountService (org.knowm.xchange.service.account.AccountService)1 DefaultTradeHistoryParamPaging (org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamPaging)1