use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.
the class EnigmaAccountDemo method generic.
private static void generic(AccountService accountService) throws IOException {
AccountInfo accountInfo = accountService.getAccountInfo();
log.info("AccountInfo as String: " + accountInfo.toString());
String depositAddress = accountService.requestDepositAddress(Currency.BTC);
log.info(depositAddress);
String result = accountService.withdrawFunds(Currency.BTC, BigDecimal.valueOf(0.002), "address");
log.info(result);
}
use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.
the class CoinbeneAccountDemo method generic.
private static void generic(AccountService accountService) throws IOException {
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println(accountInfo);
}
use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.
the class CoinoneAccountInfoDemo method generic.
private static void generic(AccountService accountService) throws IOException {
AccountInfo accountInfo = accountService.getAccountInfo();
System.out.println("Wallet: " + accountInfo);
System.out.println("ETH balance: " + accountInfo.getWallet().getBalance(Currency.ETH).getAvailable());
}
use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.
the class MercadoBitcoinAdapters method adaptAccountInfo.
/**
* Adapts a MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo> to an AccountInfo
*
* @param accountInfo The Mercado Bitcoin accountInfo
* @param userName The user name
* @return The account info
*/
public static AccountInfo adaptAccountInfo(MercadoBitcoinBaseTradeApiResult<MercadoBitcoinAccountInfo> accountInfo, String userName) {
// Adapt to XChange DTOs
Balance brlBalance = new Balance(Currency.BRL, accountInfo.getTheReturn().getFunds().getBrl());
Balance btcBalance = new Balance(Currency.BTC, accountInfo.getTheReturn().getFunds().getBtc());
Balance ltcBalance = new Balance(Currency.LTC, accountInfo.getTheReturn().getFunds().getLtc());
return new AccountInfo(userName, Wallet.Builder.from(Stream.of(brlBalance, btcBalance, ltcBalance).collect(Collectors.toList())).build());
}
use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.
the class OkCoinAdapters method adaptAccountInfo.
public static AccountInfo adaptAccountInfo(OkCoinUserInfo userInfo) {
OkCoinFunds funds = userInfo.getInfo().getFunds();
Map<String, Balance.Builder> builders = new TreeMap<>();
for (Map.Entry<String, BigDecimal> available : funds.getFree().entrySet()) {
builders.put(available.getKey(), new Balance.Builder().currency(Currency.getInstance(available.getKey())).available(available.getValue()));
}
for (Map.Entry<String, BigDecimal> frozen : funds.getFreezed().entrySet()) {
Balance.Builder builder = builders.get(frozen.getKey());
if (builder == null) {
builder = new Balance.Builder().currency(Currency.getInstance(frozen.getKey()));
}
builders.put(frozen.getKey(), builder.frozen(frozen.getValue()));
}
for (Map.Entry<String, BigDecimal> borrowed : funds.getBorrow().entrySet()) {
Balance.Builder builder = builders.get(borrowed.getKey());
if (builder == null) {
builder = new Balance.Builder().currency(Currency.getInstance(borrowed.getKey()));
}
builders.put(borrowed.getKey(), builder.borrowed(borrowed.getValue()));
}
List<Balance> wallet = new ArrayList<>(builders.size());
for (Balance.Builder builder : builders.values()) {
wallet.add(builder.build());
}
return new AccountInfo(Wallet.Builder.from(wallet).build());
}
Aggregations