use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class BitsoAdapters method adaptWallet.
public static Wallet adaptWallet(BitsoBalance bitsoBalance) {
// Adapt to XChange DTOs
Balance mxnBalance = new Balance(Currency.MXN, bitsoBalance.getMxnBalance(), bitsoBalance.getMxnAvailable(), bitsoBalance.getMxnReserved());
Balance btcBalance = new Balance(Currency.BTC, bitsoBalance.getBtcBalance(), bitsoBalance.getBtcAvailable(), bitsoBalance.getBtcReserved());
return Wallet.Builder.from(Arrays.asList(mxnBalance, btcBalance)).build();
}
use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class LatokenAccountService method getAccountInfo.
@Override
public AccountInfo getAccountInfo() throws IOException {
try {
List<LatokenBalance> latokenBalances = getLatokenBalances();
List<Balance> balances = latokenBalances.stream().map(latokenBalance -> LatokenAdapters.adaptBalance(latokenBalance)).collect(Collectors.toList());
Wallet wallet = Wallet.Builder.from(balances).build();
return new AccountInfo(null, TRADING_FEE, Arrays.asList(wallet), new Date());
} catch (LatokenException e) {
throw LatokenErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class AccountServiceIntegration method testBalances.
@Test
public void testBalances() throws Exception {
Wallet wallet = accountService.getAccountInfo().getWallet();
Assert.assertNotNull(wallet);
Map<Currency, Balance> balances = wallet.getBalances();
for (Entry<Currency, Balance> entry : balances.entrySet()) {
Currency curr = entry.getKey();
Balance bal = entry.getValue();
if (0 < bal.getAvailable().doubleValue()) {
Assert.assertSame(curr, bal.getCurrency());
Assert.assertSame(Currency.getInstance(curr.getCurrencyCode()), bal.getCurrency());
}
}
}
use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class BitbayAdapters method adaptAccountInfo.
public static AccountInfo adaptAccountInfo(String userName, BitbayAccountInfoResponse bitbayAccountInfo) {
List<Balance> balances = new ArrayList<>(bitbayAccountInfo.getBitbayBalances().size());
for (Map.Entry<String, BitbayBalance> entry : bitbayAccountInfo.getBitbayBalances().entrySet()) {
Currency currency = Currency.getInstance(entry.getKey());
BitbayBalance balance = entry.getValue();
balances.add(new Balance(currency, balance.getAvailable().add(balance.getLocked()), balance.getAvailable(), balance.getLocked()));
}
return new AccountInfo(userName, Wallet.Builder.from(balances).build());
}
use of org.knowm.xchange.dto.account.Balance in project XChange by knowm.
the class BitbayAccountService method getAccountInfo.
@Override
public AccountInfo getAccountInfo() throws IOException {
List<Wallet> wallets = new ArrayList<>();
for (BitbayBalances.BitbayBalance balance : balances()) {
Wallet wallet = Wallet.Builder.from(Arrays.asList(new Balance(Currency.getInstance(balance.getCurrency()), balance.getTotalFunds(), balance.getAvailableFunds(), balance.getLockedFunds()))).id(balance.getId()).build();
wallets.add(wallet);
}
return new AccountInfo(wallets);
}
Aggregations