Search in sources :

Example 1 with HitbtcSymbol

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);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) HitbtcSymbol(org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol) FeeTier(org.knowm.xchange.dto.meta.FeeTier) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 2 with HitbtcSymbol

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);
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Logger(org.slf4j.Logger) HitbtcMetaData(org.knowm.xchange.hitbtc.v2.dto.HitbtcMetaData) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) FeeTier(org.knowm.xchange.dto.meta.FeeTier) HitbtcMarketDataService(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataService) BigDecimal(java.math.BigDecimal) HitbtcAccountService(org.knowm.xchange.hitbtc.v2.service.HitbtcAccountService) List(java.util.List) Currency(org.knowm.xchange.currency.Currency) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) BaseExchange(org.knowm.xchange.BaseExchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Modifier(java.lang.reflect.Modifier) Map(java.util.Map) HitbtcSymbol(org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) HitbtcMarketDataServiceRaw(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataServiceRaw) HitbtcTradeService(org.knowm.xchange.hitbtc.v2.service.HitbtcTradeService) InputStream(java.io.InputStream) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) HitbtcMarketDataServiceRaw(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataServiceRaw) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Currency(org.knowm.xchange.currency.Currency) HitbtcSymbol(org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol) FeeTier(org.knowm.xchange.dto.meta.FeeTier) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 3 with HitbtcSymbol

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);
}
Also used : HitbtcMarketDataServiceRaw(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataServiceRaw) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

CurrencyPair (org.knowm.xchange.currency.CurrencyPair)3 BigDecimal (java.math.BigDecimal)2 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)2 FeeTier (org.knowm.xchange.dto.meta.FeeTier)2 HitbtcSymbol (org.knowm.xchange.hitbtc.v2.dto.HitbtcSymbol)2 HitbtcMarketDataServiceRaw (org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataServiceRaw)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Field (java.lang.reflect.Field)1 Modifier (java.lang.reflect.Modifier)1 HttpURLConnection (java.net.HttpURLConnection)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 BaseExchange (org.knowm.xchange.BaseExchange)1 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)1 Currency (org.knowm.xchange.currency.Currency)1 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)1 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)1 HitbtcMetaData (org.knowm.xchange.hitbtc.v2.dto.HitbtcMetaData)1