use of org.knowm.xchange.dto.meta.WalletHealth 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);
}
use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.
the class BitfinexAdapters method adaptMetaData.
public static ExchangeMetaData adaptMetaData(BitfinexAccountFeesResponse accountFeesResponse, int platformStatus, boolean platformStatusPresent, ExchangeMetaData metaData) {
final WalletHealth health;
if (platformStatusPresent) {
if (platformStatus == PLATFORM_STATUS_ONLINE) {
health = WalletHealth.ONLINE;
} else if (platformStatus == PLATFORM_STATUS_OFFLINE) {
health = WalletHealth.OFFLINE;
} else {
health = WalletHealth.UNKNOWN;
}
} else {
health = WalletHealth.UNKNOWN;
}
Map<Currency, CurrencyMetaData> currencies = metaData.getCurrencies();
final Map<Currency, BigDecimal> withdrawFees = accountFeesResponse.getWithdraw();
withdrawFees.forEach((currency, withdrawalFee) -> {
CurrencyMetaData newMetaData = new CurrencyMetaData(// Currency should have at least the scale of the withdrawalFee
currencies.get(currency) == null ? withdrawalFee.scale() : Math.max(withdrawalFee.scale(), currencies.get(currency).getScale()), withdrawalFee, null, health);
currencies.put(currency, newMetaData);
});
return metaData;
}
use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.
the class BittrexAdapters method adaptMetaData.
public static void adaptMetaData(List<BittrexSymbol> rawSymbols, List<BittrexCurrency> bittrexCurrencies, Map<CurrencyPair, Fee> dynamicTradingFees, ExchangeMetaData metaData) {
List<CurrencyPair> currencyPairs = BittrexAdapters.adaptCurrencyPairs(rawSymbols);
for (CurrencyPair currencyPair : currencyPairs) {
CurrencyPairMetaData defaultCurrencyPairMetaData = metaData.getCurrencyPairs().get(currencyPair);
BigDecimal resultingFee = null;
// Prioritize dynamic fee
if (dynamicTradingFees != null) {
Fee fee = dynamicTradingFees.get(currencyPair);
if (fee != null) {
resultingFee = fee.getMakerFee();
}
} else {
if (defaultCurrencyPairMetaData != null) {
resultingFee = defaultCurrencyPairMetaData.getTradingFee();
}
}
CurrencyPairMetaData newCurrencyPairMetaData;
if (defaultCurrencyPairMetaData != null) {
newCurrencyPairMetaData = new CurrencyPairMetaData(resultingFee, defaultCurrencyPairMetaData.getMinimumAmount(), defaultCurrencyPairMetaData.getMaximumAmount(), defaultCurrencyPairMetaData.getPriceScale(), defaultCurrencyPairMetaData.getVolumeScale(), defaultCurrencyPairMetaData.getFeeTiers(), defaultCurrencyPairMetaData.getTradingFeeCurrency());
} else {
newCurrencyPairMetaData = new CurrencyPairMetaData(resultingFee, null, null, null, null, null, null);
}
metaData.getCurrencyPairs().put(currencyPair, newCurrencyPairMetaData);
}
for (BittrexCurrency bittrexCurrency : bittrexCurrencies) {
WalletHealth walletHealth = WalletHealth.UNKNOWN;
if (ONLINE.equals(bittrexCurrency.getStatus())) {
walletHealth = WalletHealth.ONLINE;
} else if (OFFLINE.equals(bittrexCurrency.getStatus())) {
walletHealth = WalletHealth.OFFLINE;
}
metaData.getCurrencies().put(bittrexCurrency.getSymbol(), new CurrencyMetaData(1, BigDecimal.valueOf(bittrexCurrency.getTxFee()), null, walletHealth));
}
}
use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.
the class HuobiAdapters method getCurrencyMetaData.
private static CurrencyMetaData getCurrencyMetaData(HuobiCurrency huobiCurrency, boolean isDelisted) {
int withdrawPrecision = huobiCurrency.getWithdrawPrecision();
BigDecimal transactFeeWithdraw = new BigDecimal(huobiCurrency.getTransactFeeWithdraw());
BigDecimal minWithdrawAmt = new BigDecimal(huobiCurrency.getMinWithdrawAmt());
WalletHealth walletHealthStatus = isDelisted ? WalletHealth.OFFLINE : getWalletHealthStatus(huobiCurrency);
return new CurrencyMetaData(withdrawPrecision, transactFeeWithdraw, minWithdrawAmt, walletHealthStatus);
}
use of org.knowm.xchange.dto.meta.WalletHealth in project XChange by knowm.
the class KucoinAdapters method adaptCurrencyMetaData.
static HashMap<String, CurrencyMetaData> adaptCurrencyMetaData(List<CurrenciesResponse> list) {
HashMap<String, CurrencyMetaData> stringCurrencyMetaDataMap = new HashMap<>();
for (CurrenciesResponse currenciesResponse : list) {
BigDecimal precision = currenciesResponse.getPrecision();
BigDecimal withdrawalMinFee = null;
BigDecimal withdrawalMinSize = null;
if (currenciesResponse.getWithdrawalMinFee() != null) {
withdrawalMinFee = new BigDecimal(currenciesResponse.getWithdrawalMinFee());
}
if (currenciesResponse.getWithdrawalMinSize() != null) {
withdrawalMinSize = new BigDecimal(currenciesResponse.getWithdrawalMinSize());
}
WalletHealth walletHealth = getWalletHealth(currenciesResponse);
CurrencyMetaData currencyMetaData = new CurrencyMetaData(precision.intValue(), withdrawalMinFee, withdrawalMinSize, walletHealth);
stringCurrencyMetaDataMap.put(currenciesResponse.getCurrency(), currencyMetaData);
}
return stringCurrencyMetaDataMap;
}
Aggregations