Package com.xeiam.xchange.dto.trade

Examples of com.xeiam.xchange.dto.trade.Wallet


  public static List<Wallet> adaptWallets(Wallets anxWallets) {

    List<Wallet> wallets = new ArrayList<Wallet>();

    for (ANXWallet anxWallet : anxWallets.getANXWallets()) {
      Wallet wallet = adaptWallet(anxWallet);
      if (wallet != null) {
        wallets.add(wallet);
      }
    }
    return wallets;
View Full Code Here


  public static List<Wallet> adaptWallets(Map<String, BTCChinaValue> balances, Map<String, BTCChinaValue> frozens) {

    List<Wallet> wallets = new ArrayList<Wallet>(balances.size());

    for (Map.Entry<String, BTCChinaValue> entry : balances.entrySet()) {
      Wallet wallet;
      BTCChinaValue frozen = frozens.get(entry.getKey());
      if (frozen != null) {
        wallet = adaptWallet(entry.getValue(), frozen);
        if (wallet != null) {
          wallets.add(wallet);
View Full Code Here

    if (balance != null && frozen != null) {
      BigDecimal balanceAmount = BTCChinaUtils.valueToBigDecimal(balance);
      BigDecimal frozenAmount = BTCChinaUtils.valueToBigDecimal(frozen);
      BigDecimal cash = balanceAmount.add(frozenAmount);
      return new Wallet(balance.getCurrency(), cash);
    }
    else {
      return null;
    }
  }
View Full Code Here

    // in Wallet(s), only wallets from ANXAccountInfo.getWallets that contained data are NOT null.
    List<Wallet> wallets = ANXAdapters.adaptWallets(anxAccountInfo.getWallets());
    Assert.assertEquals(22, wallets.size());

    Assert.assertTrue(wallets.contains(new Wallet(Currencies.CAD, new BigDecimal("100000.00000"))));
    Assert.assertTrue(wallets.contains(new Wallet(Currencies.BTC, new BigDecimal("100000.01988000"))));
    Assert.assertTrue(wallets.contains(new Wallet(Currencies.DOGE, new BigDecimal("9999781.09457936"))));
  }
View Full Code Here

    OkCoinFunds funds = userInfo.getInfo().getFunds();

    // depending on china or international version
    boolean is_cny = funds.getFree().containsKey("cny");

    Wallet base = null;
    Wallet baseLoan = null;

    if (is_cny) {
      base = new Wallet(CNY, funds.getFree().get("cny").add(funds.getFreezed().get("cny")).subtract(getOrZero("cny", funds.getBorrow())), "available");
      baseLoan = new Wallet(CNY, getOrZero("cny", funds.getBorrow()), "loan");
    }
    else {
      base = new Wallet(USD, funds.getFree().get("usd").add(funds.getFreezed().get("usd")).subtract(getOrZero("usd", funds.getBorrow())), "available");
      baseLoan = new Wallet(USD, getOrZero("usd", funds.getBorrow()), "loan");
    }
    Wallet btc = new Wallet(BTC, funds.getFree().get("btc").add(funds.getFreezed().get("btc")).subtract(getOrZero("btc", funds.getBorrow())), "available");
    Wallet ltc = new Wallet(LTC, funds.getFree().get("ltc").add(funds.getFreezed().get("ltc")).subtract(getOrZero("ltc", funds.getBorrow())), "available");

    // loaned wallets
    Wallet btcLoan = new Wallet(BTC, getOrZero("btc", funds.getBorrow()), "loan");
    Wallet ltcLoan = new Wallet(LTC, getOrZero("ltc", funds.getBorrow()), "loan");

    List<Wallet> wallets = Arrays.asList(base, btc, ltc, baseLoan, btcLoan, ltcLoan);

    return new AccountInfo(null, wallets);
  }
View Full Code Here

    for (CoinfloorAssetBalance assetBalancePair : funds) {
      String currency = assetBalancePair.getAsset().toString();
      BigDecimal balance = assetBalancePair.getBalance();

      wallets.add(new Wallet(currency, balance));
    }

    AccountInfo accountInfo = new AccountInfo(null, wallets);
    synchronized (cachedDataSynchronizationObject) {
      cachedAccountInfo = accountInfo;
View Full Code Here

    synchronized (cachedDataSynchronizationObject) {
      if (cachedAccountInfo == null) {
        String currency = rawRetObj.getAsset().toString();
        BigDecimal balance = rawRetObj.getBalance();

        newWallets.add(new Wallet(currency, balance));
      }
      else {
        List<Wallet> oldWallets = cachedAccountInfo.getWallets();
        for (Wallet wallet : oldWallets) {
          if (wallet.getCurrency().equals(rawRetObj.getAsset())) {
            String currency = rawRetObj.getAsset().toString();
            BigDecimal balance = rawRetObj.getBalance();

            newWallets.add(new Wallet(currency, balance));
          }
          else {
            newWallets.add(wallet);
          }
        }
View Full Code Here

  public static List<Wallet> adaptPoloniexBalances(HashMap<String, String> poloniexBalances) {

    List<Wallet> wallets = new ArrayList<Wallet>();

    for (String currency : poloniexBalances.keySet()) {
      wallets.add(new Wallet(currency, new BigDecimal(poloniexBalances.get(currency))));
    }

    return wallets;
  }
View Full Code Here

    List<Wallet> wallets = new ArrayList<Wallet>();
    for (Entry<String, BigDecimal> funds : bterAccountInfo.getAvailableFunds().entrySet()) {
      String currency = funds.getKey().toUpperCase();
      BigDecimal amount = funds.getValue();
      wallets.add(new Wallet(currency, amount));
    }

    return new AccountInfo("", wallets);
  }
View Full Code Here

    MyFunds myFunds = getCampBXAccountInfo();
    logger.debug("myFunds = {}", myFunds);

    if (!myFunds.isError()) {
      // TODO move to adapter class
      return new AccountInfo(exchangeSpecification.getUserName(), Arrays.asList(new Wallet("BTC", myFunds.getTotalBTC()), new Wallet("USD", myFunds.getTotalUSD())));
    }
    else {
      throw new ExchangeException("Error calling getAccountInfo(): " + myFunds.getError());
    }
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.dto.trade.Wallet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.