Search in sources :

Example 1 with KrakenAssetPair

use of org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair in project XChange by knowm.

the class KrakenExchangeSymbolsDemo method raw.

private static void raw(Exchange krakenExchange) throws IOException {
    // Interested in the public market data feed (no authentication)
    KrakenMarketDataServiceRaw krakenMarketDataService = (KrakenMarketDataServiceRaw) krakenExchange.getMarketDataService();
    KrakenAssetPairs krakenAssetPairs = krakenMarketDataService.getKrakenAssetPairs();
    for (Entry<String, KrakenAssetPair> assetPairEntry : krakenAssetPairs.getAssetPairMap().entrySet()) {
        System.out.println(assetPairEntry.getKey() + ": " + assetPairEntry.getValue());
    }
}
Also used : KrakenAssetPair(org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair) KrakenMarketDataServiceRaw(org.knowm.xchange.kraken.service.KrakenMarketDataServiceRaw) KrakenAssetPairs(org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPairs)

Example 2 with KrakenAssetPair

use of org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair in project XChange by knowm.

the class KrakenAdapters method adaptToExchangeMetaData.

public static ExchangeMetaData adaptToExchangeMetaData(ExchangeMetaData originalMetaData, Map<String, KrakenAssetPair> krakenPairs, Map<String, KrakenAsset> krakenAssets) {
    Map<CurrencyPair, CurrencyPairMetaData> pairs = new HashMap<>();
    // add assets before pairs to Utils!
    KrakenUtils.setKrakenAssets(krakenAssets);
    KrakenUtils.setKrakenAssetPairs(krakenPairs);
    for (String krakenPairCode : krakenPairs.keySet()) {
        // skip dark markets!
        if (!krakenPairCode.endsWith(".d")) {
            KrakenAssetPair krakenPair = krakenPairs.get(krakenPairCode);
            pairs.put(adaptCurrencyPair(krakenPairCode), adaptPair(krakenPair, pairs.get(adaptCurrencyPair(krakenPairCode))));
        }
    }
    Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
    for (String krakenAssetCode : krakenAssets.keySet()) {
        KrakenAsset krakenAsset = krakenAssets.get(krakenAssetCode);
        Currency currencyCode = KrakenAdapters.adaptCurrency(krakenAssetCode);
        currencies.put(currencyCode, new CurrencyMetaData(krakenAsset.getScale(), null));
    }
    return new ExchangeMetaData(pairs, currencies, originalMetaData == null ? null : originalMetaData.getPublicRateLimits(), originalMetaData == null ? null : originalMetaData.getPrivateRateLimits(), originalMetaData == null ? null : originalMetaData.isShareRateLimits());
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) KrakenAssetPair(org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair) KrakenAsset(org.knowm.xchange.kraken.dto.marketdata.KrakenAsset) 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)

Example 3 with KrakenAssetPair

use of org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair in project XChange by knowm.

the class KrakenUtils method setKrakenAssetPairs.

public static void setKrakenAssetPairs(Map<String, KrakenAssetPair> pairs) {
    if (assetPairMap.isEmpty()) {
        for (Map.Entry<String, KrakenAssetPair> entry : pairs.entrySet()) {
            // skip dark markets!
            if (!entry.getKey().endsWith(".d")) {
                CurrencyPair pair = new CurrencyPair(translateKrakenCurrencyCode(entry.getValue().getBase()), translateKrakenCurrencyCode(entry.getValue().getQuote()));
                assetPairMap.put(entry.getKey(), pair);
                assetPairMapReverse.put(pair, entry.getKey());
            }
        }
    }
}
Also used : KrakenAssetPair(org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair) Map(java.util.Map) HashMap(java.util.HashMap) KrakenAdapters.adaptCurrencyPair(org.knowm.xchange.kraken.KrakenAdapters.adaptCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 4 with KrakenAssetPair

use of org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair in project XChange by knowm.

the class KrakenBaseService method getAssetPairScale.

protected int getAssetPairScale(Instrument instrument) throws IOException {
    // get decimal precision scale
    CurrencyPair cp = (CurrencyPair) instrument;
    Map<String, KrakenAssetPair> assetPairMap = kraken.getAssetPairs(cp.toString()).getResult();
    KrakenAssetPair assetPair = assetPairMap.get(cp.toString());
    int scale = assetPair.getPairScale();
    return scale;
}
Also used : KrakenAssetPair(org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

KrakenAssetPair (org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair)4 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)3 HashMap (java.util.HashMap)2 Map (java.util.Map)1 Currency (org.knowm.xchange.currency.Currency)1 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)1 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)1 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)1 KrakenAdapters.adaptCurrencyPair (org.knowm.xchange.kraken.KrakenAdapters.adaptCurrencyPair)1 KrakenAsset (org.knowm.xchange.kraken.dto.marketdata.KrakenAsset)1 KrakenAssetPairs (org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPairs)1 KrakenMarketDataServiceRaw (org.knowm.xchange.kraken.service.KrakenMarketDataServiceRaw)1