Adapts a GatecoinBalance to a Wallet

@param gatecoinBalances
@return The account info
961097
public static Wallet adaptWallet(GatecoinBalance[] gatecoinBalances) {

    ArrayList<Balance> balances = new ArrayList<>();

    for (GatecoinBalance balance : gatecoinBalances) {
      Currency ccy = Currency.getInstance(balance.getCurrency());
      balances.add(
          new Balance.Builder()
              .currency(ccy)
              .total(balance.getBalance())
              .available(balance.getAvailableBalance())
              .frozen(balance.getOpenOrder().negate())
              .withdrawing(balance.getPendingOutgoing().negate())
              .depositing(balance.getPendingIncoming().negate())
              .build());
    }
    return new Wallet(balances);
  }
667079
async function getBalance(address, tokenAddress) {
  if (tokenAddress !== gbl.constants.ADDRESS_ZERO) {
    let token = new web3.eth.Contract(abis.erc20(), tokenAddress);
    return await token.methods.balanceOf(address).call();
  } else {
    return await web3.eth.getBalance(address);
  }
}
363356
public DbxAccountInfo getAccountInfo()
        throws DbxException
    {
        String host = this.host.getApi();
        String apiPath = "1/account/info";

        return doGet(host, apiPath, null, null, new DbxRequestUtil.ResponseHandler<DbxAccountInfo>() {
            @Override
            public DbxAccountInfo handle(HttpRequestor.Response response) throws DbxException
            {
                if (response.getStatusCode() != 200) throw DbxRequestUtil.unexpectedStatus(response);

                return DbxRequestUtil.readJsonFromResponse(DbxAccountInfo.Reader, response);
            }
        });
    }
225186
public static Trades adaptTrades(
      MercadoBitcoinTransaction[] transactions, CurrencyPair currencyPair) {

    List<Trade> trades = new ArrayList<>();
    long lastTradeId = 0;
    for (MercadoBitcoinTransaction tx : transactions) {
      final long tradeId = tx.getTid();
      if (tradeId > lastTradeId) {
        lastTradeId = tradeId;
      }
      trades.add(
          new Trade(
              toOrderType(tx.getType()),
              tx.getAmount(),
              currencyPair,
              tx.getPrice(),
              DateUtils.fromMillisUtc(tx.getDate() * 1000L),
              String.valueOf(tradeId)));
    }

    return new Trades(trades, lastTradeId, Trades.TradeSortType.SortByID);
  }
397003
public Protos.Wallet walletToProto(Wallet wallet) {
        Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder();
        walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId());
        if (wallet.getDescription() != null) {
            walletBuilder.setDescription(wallet.getDescription());
        }

        for (WalletTransaction wtx : wallet.getWalletTransactions()) {
            Protos.Transaction txProto = makeTxProto(wtx);
            walletBuilder.addTransaction(txProto);
        }

        walletBuilder.addAllKey(wallet.serializeKeyChainGroupToProtobuf());

        for (Script script : wallet.getWatchedScripts()) {
            Protos.Script protoScript =
                    Protos.Script.newBuilder()
                            .setProgram(ByteString.copyFrom(script.getProgram()))
                            .setCreationTimestamp(script.getCreationTimeSeconds() * 1000)
                            .build();

            walletBuilder.addWatchedScript(protoScript);
        }

        // Populate the lastSeenBlockHash field.
        Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash();
        if (lastSeenBlockHash != null) {
            walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash));
            walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight());
        }
        if (wallet.getLastBlockSeenTimeSecs() > 0)
            walletBuilder.setLastSeenBlockTimeSecs(wallet.getLastBlockSeenTimeSecs());

        // Populate the scrypt parameters.
        KeyCrypter keyCrypter = wallet.getKeyCrypter();
        if (keyCrypter == null) {
            // The wallet is unencrypted.
            walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED);
        } else {
            // The wallet is encrypted.
            walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType());
            if (keyCrypter instanceof KeyCrypterScrypt) {
                KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter;
                walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters());
            } else {
                // Some other form of encryption has been specified that we do not know how to persist.
                throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this.");
            }
        }

        if (wallet.getKeyRotationTime() != null) {
            long timeSecs = wallet.getKeyRotationTime().getTime() / 1000;
            walletBuilder.setKeyRotationTime(timeSecs);
        }

        populateExtensions(wallet, walletBuilder);

        for (Map.Entry<String, ByteString> entry : wallet.getTags().entrySet()) {
            Protos.Tag.Builder tag = Protos.Tag.newBuilder().setTag(entry.getKey()).setData(entry.getValue());
            walletBuilder.addTags(tag);
        }

        // Populate the wallet version.
        walletBuilder.setVersion(wallet.getVersion());

        return walletBuilder.build();
    }
1235737
public static Ticker adaptTicker(KoinimTicker koinimTicker, CurrencyPair currencyPair) {

    if (!currencyPair.equals(new CurrencyPair(BTC, TRY))) {
      throw new NotAvailableFromExchangeException();
    }

    if (koinimTicker != null) {
      return new Ticker.Builder()
          .currencyPair(new CurrencyPair(BTC, Currency.TRY))
          .last(koinimTicker.getSell())
          .bid(koinimTicker.getBid())
          .ask(koinimTicker.getAsk())
          .high(koinimTicker.getHigh())
          .low(koinimTicker.getLow())
          .volume(koinimTicker.getVolume())
          .vwap(koinimTicker.getAvg())
          .build();
    }
    return null;
  }
252245
public AbucoinsAccount[] getAbucoinsAccounts() throws IOException {
    AbucoinsAccounts accounts =
        abucoinsAuthenticated.getAccounts(
            exchange.getExchangeSpecification().getApiKey(),
            signatureCreator,
            exchange.getExchangeSpecification().getPassword(),
            timestamp());

    if (accounts.getAccounts().length == 1 && accounts.getAccounts()[0].getMessage() != null)
      throw new ExchangeException(accounts.getAccounts()[0].getMessage());
    return accounts.getAccounts();
  }
614235
public static Ticker adaptTicker(
      BitcoinChartsTicker[] bitcoinChartsTickers, CurrencyPair currencyPair) {

    for (int i = 0; i < bitcoinChartsTickers.length; i++) {
      if (bitcoinChartsTickers[i].getSymbol().equals(currencyPair.counter.getCurrencyCode())) {

        BigDecimal last =
            bitcoinChartsTickers[i].getClose() != null ? bitcoinChartsTickers[i].getClose() : null;
        BigDecimal bid =
            bitcoinChartsTickers[i].getBid() != null ? bitcoinChartsTickers[i].getBid() : null;
        BigDecimal ask =
            bitcoinChartsTickers[i].getAsk() != null ? bitcoinChartsTickers[i].getAsk() : null;
        BigDecimal high =
            bitcoinChartsTickers[i].getHigh() != null ? bitcoinChartsTickers[i].getHigh() : null;
        BigDecimal low =
            bitcoinChartsTickers[i].getLow() != null ? bitcoinChartsTickers[i].getLow() : null;
        BigDecimal volume = bitcoinChartsTickers[i].getVolume();
        Date timeStamp = new Date(bitcoinChartsTickers[i].getLatestTrade() * 1000L);

        return new Ticker.Builder()
            .currencyPair(currencyPair)
            .last(last)
            .bid(bid)
            .ask(ask)
            .high(high)
            .low(low)
            .volume(volume)
            .timestamp(timeStamp)
            .build();
      }
    }
    return null;
  }
948379
@Override
  public final synchronized BalanceSheet retrieveBalance(
    final Map<String, Object> pAddParam,
      final Date pDate) throws Exception {
    getSrvBalance().recalculateAllIfNeed(pAddParam, pDate);
    BalanceSheet result = new BalanceSheet();
    result.setItsDate(pDate);
    String query = evalQueryBalance(pAddParam, pDate);
    IRecordSet<RS> recordSet = null;
    try {
      recordSet = getSrvDatabase().retrieveRecords(query);
      if (recordSet.moveToFirst()) {
        do {
          String accName = recordSet.getString("ACCOUNTNAME");
          Integer accType = recordSet.getInteger("ITSTYPE");
          String accNumber = recordSet.getString("ITSNUMBER");
          Double debit = recordSet.getDouble("DEBIT");
          Double credit = recordSet.getDouble("CREDIT");
          if (debit != 0 || credit != 0) {
            BalanceLine bl = new BalanceLine();
            bl.setAccName(accName);
            bl.setAccNumber(accNumber);
            bl.setAccType(accType);
            bl.setDebit(BigDecimal.valueOf(debit).setScale(
              getSrvAccSettings().lazyGetAccSettings(pAddParam)
                .getBalancePrecision(), getSrvAccSettings()
                  .lazyGetAccSettings(pAddParam).getRoundingMode()));
            bl.setCredit(BigDecimal.valueOf(credit).setScale(
              getSrvAccSettings().lazyGetAccSettings(pAddParam)
                .getBalancePrecision(), getSrvAccSettings()
                  .lazyGetAccSettings(pAddParam).getRoundingMode()));
            if (bl.getDebit().doubleValue() != 0
              || bl.getCredit().doubleValue() != 0) {
              result.getItsLines().add(bl);
              if (accType == 0) {
                result.setTotalLinesAssets(result.getTotalLinesAssets() + 1);
                result.setTotalAssets(result.getTotalAssets().add(bl.getDebit()
                  .subtract(bl.getCredit())));
              } else if (accType == 1) {
                result.setTotalLinesLiabilities(result
                  .getTotalLinesLiabilities() + 1);
                result.setTotalLiabilities(result.getTotalLiabilities()
                  .add(bl.getCredit().subtract(bl.getDebit())));
              } else if (accType == 2) {
                result.setTotalLinesOwnersEquity(result
                  .getTotalLinesOwnersEquity() + 1);
                result.setTotalOwnersEquity(result.getTotalOwnersEquity()
                  .add(bl.getCredit().subtract(bl.getDebit())));
              }
            }
          }
        } while (recordSet.moveToNext());
      }
    } finally {
      if (recordSet != null) {
        recordSet.close();
      }
    }
    result.setDetailRowsCount(Math.max(result.getTotalLinesAssets(),
      result.getTotalLinesLiabilities() + result
        .getTotalLinesOwnersEquity() + 3)); //3 -total l, title e ,total e
    return result;
  }
980087
def get_balance(self, acc_id=None, site='Pro', _async=False):
        
        acc_id = self.acc_id if acc_id is None else acc_id
        assert site in ['Pro', 'HADAX']
        path = f'/v1{"/" if site == "Pro" else "/hadax/"}account/accounts/{acc_id}/balance'
        # params = {'account-id': self.acct_id}
        params = {}
        return api_key_get(params, path, _async=_async)
1025338
public static AccountInfo adaptAccountInfo(ANXAccountInfo anxAccountInfo) {

    // Adapt to XChange DTOs
    AccountInfo accountInfo =
        new AccountInfo(
            anxAccountInfo.getLogin(),
            percentToFactor(anxAccountInfo.getTradeFee()),
            ANXAdapters.adaptWallet(anxAccountInfo.getWallets()));
    return accountInfo;
  }
1351168
def eth_getBalance(self, address=None, block=BLOCK_TAG_LATEST):
        
        address = address or self.eth_coinbase()
        block = validate_block(block)
        return hex_to_dec(self._call("eth_getBalance", [address, block]))
116158
public List<CoinbasePaymentMethod> getCoinbasePaymentMethods() throws IOException {
    String apiKey = exchange.getExchangeSpecification().getApiKey();
    BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();

    return coinbase
        .getPaymentMethods(Coinbase.CB_VERSION_VALUE, apiKey, signatureCreator2, timestamp)
        .getData();
  }
847182
public static UserTrades adaptTradeHistory(CoinsuperResponse<List<OrderDetail>> OrderDetails) {
    List<UserTrade> trades = new ArrayList<>();
    long lastTradeId = 0;

    for (OrderDetail orderDetail : OrderDetails.getData().getResult()) {
      OrderType orderType = OrderType.BID;

      if (orderDetail.getAction().equals("SELL")) {
        orderType = OrderType.ASK;
      }

      UserTrade trade =
          new UserTrade(
              orderType,
              orderDetail.getAmount().abs(),
              new CurrencyPair(orderDetail.getSymbol()),
              orderDetail.getPriceLimit().abs(),
              new Date(),
              Long.toString(orderDetail.getOrderNo()),
              Long.toString(orderDetail.getOrderNo()),
              new BigDecimal(orderDetail.getFee()),
              Currency.getInstance(orderDetail.getSymbol().toUpperCase()));
      lastTradeId = orderDetail.getOrderNo();
      trades.add(trade);
    }
    return new UserTrades(trades, lastTradeId, TradeSortType.SortByID);
  }
860967
public FailoverRequestBalancingStrategy getBalancer(byte[] cacheName) {
      lock.readLock().lock();
      try {
         return balancers.get(new WrappedByteArray(cacheName));
      } finally {
         lock.readLock().unlock();
      }
   }
939714
public CoinbaseAccount createCoinbaseAccount(String name) throws IOException {

    CreateCoinbaseAccountPayload payload = new CreateCoinbaseAccountPayload(name);

    String path = "/v2/accounts";
    String apiKey = exchange.getExchangeSpecification().getApiKey();
    BigDecimal timestamp = coinbase.getTime(Coinbase.CB_VERSION_VALUE).getData().getEpoch();
    String body = new ObjectMapper().writeValueAsString(payload);
    String signature = getSignature(timestamp, HttpMethod.POST, path, body);
    showCurl(HttpMethod.POST, apiKey, timestamp, signature, path, body);

    return coinbase
        .createAccount(
            MediaType.APPLICATION_JSON,
            Coinbase.CB_VERSION_VALUE,
            apiKey,
            signature,
            timestamp,
            payload)
        .getData();
  }
464435
@Override
  public UserTrades getTradeHistory(TradeHistoryParams params)
      throws ExchangeException, IOException {

    CurrencyPair pair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
    List<GateioTrade> userTrades = getGateioTradeHistory(pair).getTrades();

    return GateioAdapters.adaptUserTrades(userTrades);
  }