Search in sources :

Example 11 with CurrencyMetaData

use of org.knowm.xchange.dto.meta.CurrencyMetaData in project XChange by knowm.

the class IdexExchange method getExchangeMetaData.

@Override
public final ExchangeMetaData getExchangeMetaData() {
    ReturnCurrenciesResponse allCurrenciesStatic = null;
    try {
        allCurrenciesStatic = allCurrenciesStatic();
    } catch (IOException e) {
        e.printStackTrace();
    }
    LinkedHashMap<CurrencyPair, CurrencyPairMetaData> currencyPairs = new LinkedHashMap<>();
    ReturnTickerRequestedWithNull allTickers = IdexMarketDataService.Companion.allTickers;
    allTickers.keySet().forEach(s -> currencyPairs.put(IdexExchange.Companion.getCurrencyPair(s), unavailableCPMeta));
    LinkedHashMap<Currency, CurrencyMetaData> linkedHashMap = new LinkedHashMap<>();
    allCurrenciesStatic.forEach((key, value) -> linkedHashMap.put(Currency.getInstance(key), new IdexCurrencyMeta(0, ZERO, value.getAddress(), value.getName(), value.getDecimals())));
    RateLimit[] publicRateLimits = {};
    return new ExchangeMetaData(currencyPairs, linkedHashMap, publicRateLimits, publicRateLimits, Boolean.FALSE);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) IdexCurrencyMeta(org.knowm.xchange.idex.IdexExchange.Companion.IdexCurrencyMeta) ReturnCurrenciesResponse(org.knowm.xchange.idex.dto.ReturnCurrenciesResponse) IOException(java.io.IOException) ReturnTickerRequestedWithNull(org.knowm.xchange.idex.dto.ReturnTickerRequestedWithNull) LinkedHashMap(java.util.LinkedHashMap) RateLimit(org.knowm.xchange.dto.meta.RateLimit) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 12 with CurrencyMetaData

use of org.knowm.xchange.dto.meta.CurrencyMetaData in project XChange by knowm.

the class BityAdapters method adaptMetaData.

public static ExchangeMetaData adaptMetaData(List<BityPair> rawSymbols, ExchangeMetaData metaData) {
    List<CurrencyPair> currencyPairs = BityAdapters.adaptCurrencyPairs(rawSymbols);
    Map<CurrencyPair, CurrencyPairMetaData> pairsMap = metaData.getCurrencyPairs();
    Map<Currency, CurrencyMetaData> currenciesMap = metaData.getCurrencies();
    for (CurrencyPair c : currencyPairs) {
        if (!pairsMap.containsKey(c)) {
            pairsMap.put(c, null);
        }
        if (!currenciesMap.containsKey(c.base)) {
            currenciesMap.put(c.base, null);
        }
        if (!currenciesMap.containsKey(c.counter)) {
            currenciesMap.put(c.counter, null);
        }
    }
    return metaData;
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Currency(org.knowm.xchange.currency.Currency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 13 with CurrencyMetaData

use of org.knowm.xchange.dto.meta.CurrencyMetaData 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 14 with CurrencyMetaData

use of org.knowm.xchange.dto.meta.CurrencyMetaData in project XChange by knowm.

the class CoinbaseProAdapters method adaptToExchangeMetaData.

public static ExchangeMetaData adaptToExchangeMetaData(ExchangeMetaData exchangeMetaData, CoinbaseProProduct[] products, CoinbaseProCurrency[] cbCurrencies) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData == null ? new HashMap<>() : exchangeMetaData.getCurrencyPairs();
    Map<Currency, CurrencyMetaData> currencies = exchangeMetaData == null ? new HashMap<>() : exchangeMetaData.getCurrencies();
    for (CoinbaseProProduct product : products) {
        if (!"online".equals(product.getStatus())) {
            continue;
        }
        CurrencyPair pair = adaptCurrencyPair(product);
        CurrencyPairMetaData staticMetaData = currencyPairs.get(pair);
        int baseScale = numberOfDecimals(product.getBaseIncrement());
        int priceScale = numberOfDecimals(product.getQuoteIncrement());
        boolean marketOrderAllowed = !product.isLimitOnly();
        currencyPairs.put(pair, new CurrencyPairMetaData(// Trading fee at Coinbase is 0.5 %
        new BigDecimal("0.50"), product.getBaseMinSize(), product.getBaseMaxSize(), product.getMinMarketFunds(), product.getMaxMarketFunds(), baseScale, priceScale, null, staticMetaData != null ? staticMetaData.getFeeTiers() : null, null, pair.counter, marketOrderAllowed));
    }
    Arrays.stream(cbCurrencies).forEach(currency -> currencies.put(adaptCurrency(currency), new CurrencyMetaData(numberOfDecimals(currency.getMaxPrecision()), BigDecimal.ZERO, currency.getDetails().getMinWithdrawalAmount(), "online".equals(currency.getStatus()) ? WalletHealth.ONLINE : WalletHealth.OFFLINE)));
    return new ExchangeMetaData(currencyPairs, currencies, exchangeMetaData == null ? null : exchangeMetaData.getPublicRateLimits(), exchangeMetaData == null ? null : exchangeMetaData.getPrivateRateLimits(), true);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) CoinbaseProCurrency(org.knowm.xchange.coinbasepro.dto.marketdata.CoinbaseProCurrency) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) CoinbaseProProduct(org.knowm.xchange.coinbasepro.dto.marketdata.CoinbaseProProduct)

Example 15 with CurrencyMetaData

use of org.knowm.xchange.dto.meta.CurrencyMetaData in project XChange by knowm.

the class FtxAdapters method adaptExchangeMetaData.

public static ExchangeMetaData adaptExchangeMetaData(FtxMarketsDto marketsDto) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>();
    Map<Currency, CurrencyMetaData> currency = new HashMap<>();
    marketsDto.getMarketList().forEach(ftxMarketDto -> {
        CurrencyPairMetaData currencyPairMetaData = new CurrencyPairMetaData.Builder().amountStepSize(ftxMarketDto.getPriceIncrement()).minimumAmount(ftxMarketDto.getSizeIncrement()).priceScale(ftxMarketDto.getPriceIncrement().scale()).baseScale(ftxMarketDto.getSizeIncrement().scale()).build();
        if ("spot".equals(ftxMarketDto.getType())) {
            CurrencyPair currencyPair = new CurrencyPair(ftxMarketDto.getBaseCurrency(), ftxMarketDto.getQuoteCurrency());
            currencyPairs.put(currencyPair, currencyPairMetaData);
            if (!currency.containsKey(currencyPair.base)) {
                currency.put(currencyPair.base, new CurrencyMetaData(ftxMarketDto.getSizeIncrement().scale(), BigDecimal.ZERO));
            }
            if (!currency.containsKey(currencyPair.counter)) {
                currency.put(currencyPair.counter, new CurrencyMetaData(ftxMarketDto.getPriceIncrement().scale(), BigDecimal.ZERO));
            }
        } else if ("future".equals(ftxMarketDto.getType()) && ftxMarketDto.getName().contains("-")) {
            CurrencyPair futuresContract = new CurrencyPair(ftxMarketDto.getName());
            currencyPairs.put(futuresContract, currencyPairMetaData);
        }
    });
    RateLimit[] rateLimits = { new RateLimit(30, 1, TimeUnit.SECONDS) };
    return new ExchangeMetaData(currencyPairs, currency, rateLimits, rateLimits, true);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) RateLimit(org.knowm.xchange.dto.meta.RateLimit) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) HashMap(java.util.HashMap) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)42 Currency (org.knowm.xchange.currency.Currency)34 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)32 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)32 BigDecimal (java.math.BigDecimal)19 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)17 HashMap (java.util.HashMap)14 FeeTier (org.knowm.xchange.dto.meta.FeeTier)7 WalletHealth (org.knowm.xchange.dto.meta.WalletHealth)7 Map (java.util.Map)6 Test (org.junit.Test)6 IOException (java.io.IOException)5 Fee (org.knowm.xchange.dto.account.Fee)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 InputStream (java.io.InputStream)2 Field (java.lang.reflect.Field)2 Modifier (java.lang.reflect.Modifier)2 HttpURLConnection (java.net.HttpURLConnection)2