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;
}
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);
}
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();
}
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());
}
Aggregations