Search in sources :

Example 11 with AccountInfo

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);
}
Also used : AccountInfo(org.knowm.xchange.dto.account.AccountInfo)

Example 12 with AccountInfo

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);
}
Also used : AccountInfo(org.knowm.xchange.dto.account.AccountInfo)

Example 13 with 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());
}
Also used : AccountInfo(org.knowm.xchange.dto.account.AccountInfo)

Example 14 with AccountInfo

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());
}
Also used : Balance(org.knowm.xchange.dto.account.Balance) MercadoBitcoinAccountInfo(org.knowm.xchange.mercadobitcoin.dto.account.MercadoBitcoinAccountInfo) AccountInfo(org.knowm.xchange.dto.account.AccountInfo)

Example 15 with AccountInfo

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());
}
Also used : OkCoinFunds(org.knowm.xchange.okcoin.dto.account.OkCoinFunds) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) BigDecimal(java.math.BigDecimal) Map(java.util.Map) TreeMap(java.util.TreeMap) Balance(org.knowm.xchange.dto.account.Balance) AccountInfo(org.knowm.xchange.dto.account.AccountInfo)

Aggregations

AccountInfo (org.knowm.xchange.dto.account.AccountInfo)96 Balance (org.knowm.xchange.dto.account.Balance)50 Wallet (org.knowm.xchange.dto.account.Wallet)35 BigDecimal (java.math.BigDecimal)34 ArrayList (java.util.ArrayList)25 Test (org.junit.Test)23 Currency (org.knowm.xchange.currency.Currency)18 Date (java.util.Date)13 AccountService (org.knowm.xchange.service.account.AccountService)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 InputStream (java.io.InputStream)9 Exchange (org.knowm.xchange.Exchange)9 Map (java.util.Map)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Arrays (java.util.Arrays)3 FileNotFoundException (java.io.FileNotFoundException)2 ZERO (java.math.BigDecimal.ZERO)2 Collection (java.util.Collection)2