use of org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol in project XChange by knowm.
the class HitbtcAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(List<HitbtcSymbol> symbols, Map<Currency, CurrencyMetaData> currencies, Map<CurrencyPair, CurrencyPairMetaData> currencyPairs) {
if (symbols != null) {
for (HitbtcSymbol symbol : symbols) {
CurrencyPair pair = adaptSymbol(symbol);
BigDecimal tickSize = symbol.getTickSize();
// not 100% sure this is correct
int priceScale = tickSize.scale();
BigDecimal tradingFee = symbol.getTakeLiquidityRate();
BigDecimal minimumAmount = symbol.getQuantityIncrement();
BigDecimal maximumAmount = null;
FeeTier[] feeTiers = null;
if (currencyPairs.containsKey(pair)) {
CurrencyPairMetaData existing = currencyPairs.get(pair);
minimumAmount = existing.getMinimumAmount();
maximumAmount = existing.getMaximumAmount();
feeTiers = existing.getFeeTiers();
}
CurrencyPairMetaData meta = new CurrencyPairMetaData(tradingFee, minimumAmount, maximumAmount, priceScale, feeTiers);
currencyPairs.put(pair, meta);
}
}
return new ExchangeMetaData(currencyPairs, currencies, null, null, null);
}
use of org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol in project XChange by knowm.
the class HitbtcExchange method remoteInit.
@Override
public void remoteInit() throws IOException {
HitbtcMarketDataServiceRaw dataService = ((HitbtcMarketDataServiceRaw) marketDataService);
List<HitbtcSymbol> hitbtcSymbols = dataService.getHitbtcSymbols();
Map<Currency, CurrencyMetaData> currencies = dataService.getHitbtcCurrencies().stream().collect(Collectors.toMap(hitbtcCurrency -> new Currency(hitbtcCurrency.getId()), hitbtcCurrency -> new CurrencyMetaData(null, hitbtcCurrency.getPayoutFee())));
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = hitbtcSymbols.stream().collect(Collectors.toMap(hitbtcSymbol -> new CurrencyPair(new Currency(hitbtcSymbol.getBaseCurrency()), new Currency(hitbtcSymbol.getQuoteCurrency())), hitbtcSymbol -> new CurrencyPairMetaData((BigDecimal) null, hitbtcSymbol.getQuantityIncrement(), (BigDecimal) null, hitbtcSymbol.getTickSize().scale(), (FeeTier[]) null)));
exchangeMetaData = HitbtcAdapters.adaptToExchangeMetaData(hitbtcSymbols, currencies, currencyPairs);
}
use of org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol in project XChange by knowm.
the class HitbtcAdapters method adaptSymbol.
public static CurrencyPair adaptSymbol(String symbol) {
if (symbols.isEmpty()) {
try {
HitbtcExchange exchange = ExchangeFactory.INSTANCE.createExchange(HitbtcExchange.class);
symbols = new HitbtcMarketDataServiceRaw(exchange).getHitbtcSymbols().stream().collect(Collectors.toMap(hitbtcSymbol -> hitbtcSymbol.getBaseCurrency() + hitbtcSymbol.getQuoteCurrency(), hitbtcSymbol -> new CurrencyPair(hitbtcSymbol.getBaseCurrency(), hitbtcSymbol.getQuoteCurrency())));
} catch (Exception ignored) {
}
}
return symbols.containsKey(symbol) ? symbols.get(symbol) : guessSymbol(symbol);
}
Aggregations