Search in sources :

Example 1 with IndependentReserveBalance

use of org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance in project XChange by knowm.

the class IndependentReserveAccountServiceRaw method getIndependentReserveBalance.

public IndependentReserveBalance getIndependentReserveBalance() throws IOException {
    Long nonce = exchange.getNonceFactory().createValue();
    String apiKey = exchange.getExchangeSpecification().getApiKey();
    AuthAggregate authAggregate = new AuthAggregate(apiKey, nonce);
    authAggregate.setSignature(signatureCreator.digestParamsToString(ExchangeEndpoint.GET_ACCOUNTS, nonce, authAggregate.getParameters()));
    IndependentReserveBalance independentReserveBalance = independentReserveAuthenticated.getBalance(authAggregate);
    if (independentReserveBalance == null) {
        throw new ExchangeException("Error getting balance");
    }
    return independentReserveBalance;
}
Also used : AuthAggregate(org.knowm.xchange.independentreserve.dto.auth.AuthAggregate) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) IndependentReserveBalance(org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance)

Example 2 with IndependentReserveBalance

use of org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance in project XChange by knowm.

the class IndependentReserveAccountDemo method raw.

private static void raw(IndependentReserveAccountService accountService) throws IOException {
    // Get the account information
    IndependentReserveBalance balance = accountService.getIndependentReserveBalance();
    System.out.println("Balance: " + balance);
}
Also used : IndependentReserveBalance(org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance)

Example 3 with IndependentReserveBalance

use of org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance in project XChange by knowm.

the class IndependentReserveAdapters method adaptWallet.

public static Wallet adaptWallet(IndependentReserveBalance independentReserveBalance) {
    List<Balance> balances = new ArrayList<>();
    for (IndependentReserveAccount balanceAccount : independentReserveBalance.getIndependentReserveAccounts()) {
        Currency currency = Currency.getInstance(balanceAccount.getCurrencyCode().toUpperCase());
        balances.add(new Balance(currency.getCommonlyUsedCurrency(), balanceAccount.getTotalBalance(), balanceAccount.getAvailableBalance()));
    }
    return Wallet.Builder.from(balances).build();
}
Also used : IndependentReserveAccount(org.knowm.xchange.independentreserve.dto.account.IndependentReserveAccount) Currency(org.knowm.xchange.currency.Currency) ArrayList(java.util.ArrayList) Balance(org.knowm.xchange.dto.account.Balance) IndependentReserveBalance(org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance)

Example 4 with IndependentReserveBalance

use of org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance 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

IndependentReserveBalance (org.knowm.xchange.independentreserve.dto.account.IndependentReserveBalance)4 Currency (org.knowm.xchange.currency.Currency)2 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)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 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 AccountInfo (org.knowm.xchange.dto.account.AccountInfo)1 Balance (org.knowm.xchange.dto.account.Balance)1 Fee (org.knowm.xchange.dto.account.Fee)1 FundingRecord (org.knowm.xchange.dto.account.FundingRecord)1 IndependentReserveAdapters (org.knowm.xchange.independentreserve.IndependentReserveAdapters)1 IndependentReserveHttpStatusException (org.knowm.xchange.independentreserve.dto.IndependentReserveHttpStatusException)1 IndependentReserveAccount (org.knowm.xchange.independentreserve.dto.account.IndependentReserveAccount)1