Search in sources :

Example 1 with AssetDetail

use of org.knowm.xchange.binance.dto.account.AssetDetail in project XChange by knowm.

the class BinanceAdapters method adaptCurrencyMetaData.

static CurrencyMetaData adaptCurrencyMetaData(Map<Currency, CurrencyMetaData> currencies, Currency currency, Map<String, AssetDetail> assetDetailMap, int precision) {
    if (assetDetailMap != null) {
        AssetDetail asset = assetDetailMap.get(currency.getCurrencyCode());
        if (asset != null) {
            BigDecimal withdrawalFee = asset.getWithdrawFee().stripTrailingZeros();
            BigDecimal minWithdrawalAmount = new BigDecimal(asset.getMinWithdrawAmount()).stripTrailingZeros();
            WalletHealth walletHealth = getWalletHealth(asset.isDepositStatus(), asset.isWithdrawStatus());
            return new CurrencyMetaData(precision, withdrawalFee, minWithdrawalAmount, walletHealth);
        }
    }
    BigDecimal withdrawalFee = null;
    BigDecimal minWithdrawalAmount = null;
    if (currencies.containsKey(currency)) {
        CurrencyMetaData currencyMetaData = currencies.get(currency);
        withdrawalFee = currencyMetaData.getWithdrawalFee();
        minWithdrawalAmount = currencyMetaData.getMinWithdrawalAmount();
    }
    return new CurrencyMetaData(precision, withdrawalFee, minWithdrawalAmount);
}
Also used : WalletHealth(org.knowm.xchange.dto.meta.WalletHealth) AssetDetail(org.knowm.xchange.binance.dto.account.AssetDetail) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) BigDecimal(java.math.BigDecimal)

Example 2 with AssetDetail

use of org.knowm.xchange.binance.dto.account.AssetDetail in project XChange by knowm.

the class BinanceExchange method remoteInit.

@Override
public void remoteInit() {
    try {
        BinanceMarketDataService marketDataService = (BinanceMarketDataService) this.marketDataService;
        exchangeInfo = marketDataService.getExchangeInfo();
        BinanceAccountService accountService = (BinanceAccountService) getAccountService();
        Map<String, AssetDetail> assetDetailMap = null;
        if (!usingSandbox() && isAuthenticated()) {
            // not available in sndbox
            assetDetailMap = accountService.getAssetDetails();
        }
        postInit(assetDetailMap);
    } catch (Exception e) {
        throw new ExchangeException("Failed to initialize: " + e.getMessage(), e);
    }
}
Also used : AssetDetail(org.knowm.xchange.binance.dto.account.AssetDetail) BinanceMarketDataService(org.knowm.xchange.binance.service.BinanceMarketDataService) BinanceAccountService(org.knowm.xchange.binance.service.BinanceAccountService) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException)

Example 3 with AssetDetail

use of org.knowm.xchange.binance.dto.account.AssetDetail in project XChange by knowm.

the class BinanceUsExchange method remoteInit.

@Override
public void remoteInit() {
    BinanceMarketDataService marketDataService = (BinanceMarketDataService) this.marketDataService;
    try {
        exchangeInfo = marketDataService.getExchangeInfo();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Map<String, AssetDetail> assetDetailMap = null;
    postInit(assetDetailMap);
}
Also used : AssetDetail(org.knowm.xchange.binance.dto.account.AssetDetail) BinanceMarketDataService(org.knowm.xchange.binance.service.BinanceMarketDataService) IOException(java.io.IOException)

Aggregations

AssetDetail (org.knowm.xchange.binance.dto.account.AssetDetail)3 BinanceMarketDataService (org.knowm.xchange.binance.service.BinanceMarketDataService)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 BinanceAccountService (org.knowm.xchange.binance.service.BinanceAccountService)1 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)1 WalletHealth (org.knowm.xchange.dto.meta.WalletHealth)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1