Search in sources :

Example 26 with CurrencyPairMetaData

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

the class BitcointoyouExchangeIntegration method testExchangeMetaData.

@Test
public void testExchangeMetaData() throws Exception {
    final SoftAssertions softly = new SoftAssertions();
    ExchangeMetaData exchangeMetaData = sut.getExchangeMetaData();
    softly.assertThat(exchangeMetaData).isNotNull();
    softly.assertThat(exchangeMetaData.isShareRateLimits()).isTrue();
    softly.assertThat(exchangeMetaData.getCurrencies()).size().isEqualTo(1);
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs();
    softly.assertThat(currencyPairs).size().isEqualTo(1);
    softly.assertThat(currencyPairs).size().isEqualTo(1);
    softly.assertThat(exchangeMetaData.isShareRateLimits()).isTrue();
    RateLimit rateLimit = exchangeMetaData.getPrivateRateLimits()[0];
    softly.assertThat(rateLimit.getPollDelayMillis()).isEqualTo(10000);
    softly.assertAll();
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) RateLimit(org.knowm.xchange.dto.meta.RateLimit) SoftAssertions(org.assertj.core.api.SoftAssertions) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Example 27 with CurrencyPairMetaData

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

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

the class BitflyerAdapters method adaptMetaData.

public static ExchangeMetaData adaptMetaData(List<BitflyerMarket> markets) {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>();
    Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
    for (BitflyerMarket market : markets) {
        CurrencyPair pair = adaptCurrencyPair(market.getProductCode());
        currencyPairs.put(pair, null);
    }
    return new ExchangeMetaData(currencyPairs, currencies, null, null, false);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) BitflyerMarket(org.knowm.xchange.bitflyer.dto.account.BitflyerMarket) 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 29 with CurrencyPairMetaData

use of org.knowm.xchange.dto.meta.CurrencyPairMetaData in project wildfly-camel by wildfly-extras.

the class XChangeMetadataIntegrationTest method testCurrencyPairMetaData.

@Test
public void testCurrencyPairMetaData() throws Exception {
    try (CamelContext camelctx = new DefaultCamelContext()) {
        Assume.assumeTrue(checkAPIConnection());
        camelctx.addRoutes(createRouteBuilder());
        camelctx.start();
        ProducerTemplate template = camelctx.createProducerTemplate();
        CurrencyPairMetaData metadata = template.requestBody("direct:currencyPairMetaData", CurrencyPair.EOS_ETH, CurrencyPairMetaData.class);
        Assert.assertNotNull("CurrencyPairMetaData not null", metadata);
        metadata = template.requestBodyAndHeader("direct:currencyPairMetaData", null, HEADER_CURRENCY_PAIR, CurrencyPair.EOS_ETH, CurrencyPairMetaData.class);
        Assert.assertNotNull("CurrencyPairMetaData not null", metadata);
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) ProducerTemplate(org.apache.camel.ProducerTemplate) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 30 with CurrencyPairMetaData

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

the class BitfinexAdapters method adaptMetaData.

public static ExchangeMetaData adaptMetaData(List<CurrencyPair> currencyPairs, ExchangeMetaData metaData) {
    Map<CurrencyPair, CurrencyPairMetaData> pairsMap = metaData.getCurrencyPairs();
    Map<Currency, CurrencyMetaData> currenciesMap = metaData.getCurrencies();
    // Remove pairs that are no-longer in use
    pairsMap.keySet().retainAll(currencyPairs);
    // Remove currencies that are no-longer in use
    Set<Currency> currencies = currencyPairs.stream().flatMap(pair -> Stream.of(pair.base, pair.counter)).collect(Collectors.toSet());
    currenciesMap.keySet().retainAll(currencies);
    // Add missing pairs and currencies
    for (CurrencyPair c : currencyPairs) {
        if (!pairsMap.containsKey(c)) {
            pairsMap.put(c, null);
        }
        if (!currenciesMap.containsKey(c.base)) {
            currenciesMap.put(c.base, new CurrencyMetaData(2, // When missing, add default meta-data with scale of 2 (Bitfinex's minimal
            null));
        // scale)
        }
        if (!currenciesMap.containsKey(c.counter)) {
            currenciesMap.put(c.counter, new CurrencyMetaData(2, null));
        }
    }
    return metaData;
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) StopOrder(org.knowm.xchange.dto.trade.StopOrder) Arrays(java.util.Arrays) OrderType(org.knowm.xchange.dto.Order.OrderType) Date(java.util.Date) BitfinexBalancesResponse(org.knowm.xchange.bitfinex.v1.dto.account.BitfinexBalancesResponse) LoggerFactory(org.slf4j.LoggerFactory) BitfinexLendLevel(org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLendLevel) BitfinexOrderType(org.knowm.xchange.bitfinex.v1.BitfinexOrderType) Balance(org.knowm.xchange.dto.account.Balance) BigDecimal(java.math.BigDecimal) CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) BitfinexDepositWithdrawalHistoryResponse(org.knowm.xchange.bitfinex.v1.dto.account.BitfinexDepositWithdrawalHistoryResponse) Map(java.util.Map) BitfinexTrade(org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTrade) BitfinexPublicTrade(org.knowm.xchange.bitfinex.v2.dto.marketdata.BitfinexPublicTrade) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OrderStatus(org.knowm.xchange.dto.Order.OrderStatus) Wallet(org.knowm.xchange.dto.account.Wallet) FixedRateLoanOrder(org.knowm.xchange.dto.trade.FixedRateLoanOrder) MathContext(java.math.MathContext) BitfinexAccountInfosResponse(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexAccountInfosResponse) BitfinexTradeResponse(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexTradeResponse) Collection(java.util.Collection) Set(java.util.Set) UserTrades(org.knowm.xchange.dto.trade.UserTrades) UserTrade(org.knowm.xchange.dto.trade.UserTrade) Collectors(java.util.stream.Collectors) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) List(java.util.List) Currency(org.knowm.xchange.currency.Currency) Stream(java.util.stream.Stream) BitfinexLevel(org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexLevel) Entry(java.util.Map.Entry) Optional(java.util.Optional) BitfinexTicker(org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexTicker) BitfinexDepth(org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexDepth) Movement(org.knowm.xchange.bitfinex.v2.dto.account.Movement) CurrencyPairDeserializer(org.knowm.xchange.utils.jackson.CurrencyPairDeserializer) BitfinexUtils(org.knowm.xchange.bitfinex.v1.BitfinexUtils) BitfinexOrderStatusResponse(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexOrderStatusResponse) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) FundingRecord(org.knowm.xchange.dto.account.FundingRecord) Supplier(java.util.function.Supplier) OrderBook(org.knowm.xchange.dto.marketdata.OrderBook) ArrayList(java.util.ArrayList) TradeSortType(org.knowm.xchange.dto.marketdata.Trades.TradeSortType) BitfinexTickerFundingCurrency(org.knowm.xchange.bitfinex.v2.dto.marketdata.BitfinexTickerFundingCurrency) Order(org.knowm.xchange.dto.Order) BitfinexSymbolDetail(org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexSymbolDetail) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) Ticker(org.knowm.xchange.dto.marketdata.Ticker) Logger(org.slf4j.Logger) Fee(org.knowm.xchange.dto.account.Fee) BitfinexAccountFeesResponse(org.knowm.xchange.bitfinex.v1.dto.account.BitfinexAccountFeesResponse) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Trades(org.knowm.xchange.dto.marketdata.Trades) FloatingRateLoanOrder(org.knowm.xchange.dto.trade.FloatingRateLoanOrder) BitfinexTradingFeeResponse(org.knowm.xchange.bitfinex.v1.dto.account.BitfinexTradingFeeResponse) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) Trade(org.knowm.xchange.dto.marketdata.Trade) BitfinexOrderFlags(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexOrderFlags) BitfinexTickerTraidingPair(org.knowm.xchange.bitfinex.v2.dto.marketdata.BitfinexTickerTraidingPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) WalletHealth(org.knowm.xchange.dto.meta.WalletHealth) DateUtils(org.knowm.xchange.utils.DateUtils) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Currency(org.knowm.xchange.currency.Currency) BitfinexTickerFundingCurrency(org.knowm.xchange.bitfinex.v2.dto.marketdata.BitfinexTickerFundingCurrency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)52 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)45 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)33 Currency (org.knowm.xchange.currency.Currency)32 BigDecimal (java.math.BigDecimal)22 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)22 HashMap (java.util.HashMap)16 Test (org.junit.Test)10 FeeTier (org.knowm.xchange.dto.meta.FeeTier)10 IOException (java.io.IOException)7 Map (java.util.Map)7 Fee (org.knowm.xchange.dto.account.Fee)6 ArrayList (java.util.ArrayList)5 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 RateLimit (org.knowm.xchange.dto.meta.RateLimit)4 WalletHealth (org.knowm.xchange.dto.meta.WalletHealth)4 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2