org.knowm.xchange.dto.account.Balance Java Examples
The following examples show how to use
org.knowm.xchange.dto.account.Balance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HuobiAdapters.java From zheshiyigeniubidexiangmu with MIT License | 6 votes |
public static Wallet adaptWallet(Map<String, HuobiBalanceSum> huobiWallet) { List<Balance> balances = new ArrayList<>(huobiWallet.size()); for (Map.Entry<String, HuobiBalanceSum> record : huobiWallet.entrySet()) { try { Currency currency = adaptCurrency(record.getKey()); Balance balance = new Balance( currency, record.getValue().getTotal(), record.getValue().getAvailable(), record.getValue().getFrozen()); balances.add(balance); } catch (ExchangeException e) { // It might be a new currency. Ignore the exception and continue with other currency. } } return new Wallet(balances); }
Example #2
Source File: CoinbaseAccountService.java From zheshiyigeniubidexiangmu with MIT License | 6 votes |
@Override public AccountInfo getAccountInfo() throws IOException { List<Wallet> wallets = new ArrayList<>(); List<CoinbaseAccountData.CoinbaseAccount> coinbaseAccounts = getCoinbaseAccounts(); for (CoinbaseAccountData.CoinbaseAccount coinbaseAccount : coinbaseAccounts) { CoinbaseAmount balance = coinbaseAccount.getBalance(); Wallet wallet = new Wallet( coinbaseAccount.getId(), new Balance(Currency.getInstance(balance.getCurrency()), balance.getAmount())); wallets.add(wallet); } return new AccountInfo(wallets); }
Example #3
Source File: XChangeAccountIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void testBalances() throws Exception { try (CamelContext camelctx = new DefaultCamelContext()) { Assume.assumeTrue(checkAPIConnection()); camelctx.addRoutes(createRouteBuilder()); camelctx.start(); Assume.assumeTrue(hasAPICredentials(camelctx)); ProducerTemplate template = camelctx.createProducerTemplate(); List<Balance> balances = template.requestBody("direct:balances", null, List.class); Assert.assertNotNull("Balances not null", balances); balances.forEach(b -> System.out.println(b)); } }
Example #4
Source File: ExchangeBuilder.java From arbitrader with MIT License | 5 votes |
public ExchangeBuilder withBalance(Currency currency, BigDecimal amount) { Balance balance = new Balance.Builder() .currency(currency) .available(amount) .build(); balances.add(balance); return this; }
Example #5
Source File: BitmexAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public static Wallet adaptWallet(Map<String, BigDecimal> bitmexWallet) { List<Balance> balances = new ArrayList<>(bitmexWallet.size()); for (Entry<String, BigDecimal> balancePair : bitmexWallet.entrySet()) { Currency currency = adaptCurrency(balancePair.getKey()); Balance balance = new Balance(currency, balancePair.getValue()); balances.add(balance); } return new Wallet(balances); }
Example #6
Source File: BinanceAccountService.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
@Override public AccountInfo getAccountInfo() throws IOException { Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow"); BinanceAccountInformation acc = super.account(recvWindow, getTimestamp()); List<Balance> balances = acc.balances .stream() .map(b -> new Balance(b.getCurrency(), b.getTotal(), b.getAvailable())) .collect(Collectors.toList()); return new AccountInfo(new Wallet(balances)); }
Example #7
Source File: BiboxAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
private static Balance adaptBalance(BiboxCoin coin) { return new Balance.Builder() .currency(Currency.getInstance(coin.getSymbol())) .available(coin.getBalance()) .frozen(coin.getFreeze()) .total(coin.getBalance().add(coin.getFreeze())) .build(); }
Example #8
Source File: OkCoinAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public static AccountInfo adaptAccountInfoFutures(OkCoinFuturesUserInfoCross futureUserInfo) { OkCoinFuturesInfoCross info = futureUserInfo.getInfo(); OkcoinFuturesFundsCross btcFunds = info.getBtcFunds(); OkcoinFuturesFundsCross ltcFunds = info.getLtcFunds(); OkcoinFuturesFundsCross bchFunds = info.getBchFunds(); Balance btcBalance = new Balance(BTC, btcFunds.getAccountRights()); Balance ltcBalance = new Balance(LTC, ltcFunds.getAccountRights()); Balance bchBalance = new Balance(BCH, bchFunds.getAccountRights()); return new AccountInfo(new Wallet(zeroUsdBalance, btcBalance, ltcBalance, bchBalance)); }
Example #9
Source File: CoinbaseAdapters.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
public static AccountInfo adaptAccountInfo(CoinbaseUser user) { final String username = user.getEmail(); final CoinbaseMoney money = user.getBalance(); final Balance balance = new Balance(Currency.getInstance(money.getCurrency()), money.getAmount()); final AccountInfo accountInfoTemporaryName = new AccountInfo(username, new Wallet(balance)); return accountInfoTemporaryName; }
Example #10
Source File: BiboxAdapters.java From zheshiyigeniubidexiangmu with MIT License | 4 votes |
private static Wallet adaptWallet(List<BiboxCoin> coins) { List<Balance> balances = coins.stream().map(BiboxAdapters::adaptBalance).collect(Collectors.toList()); return new Wallet(balances); }