Search in sources :

Example 21 with CurrencyPair

use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.

the class FtxStreamingMarketDataServiceIntegration method orderbookCorrectnessTest.

@Test
@Ignore
public void orderbookCorrectnessTest() throws Exception {
    StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(FtxStreamingExchange.class);
    exchange.connect(ProductSubscription.create().addAll(new CurrencyPair("BTC-PERP")).build()).blockingAwait();
    Disposable dis = exchange.getStreamingMarketDataService().getOrderBook(new CurrencyPair("BTC-PERP")).retry().subscribe(orderBook -> {
        if (orderBook.getBids().size() > 0 && orderBook.getAsks().size() > 0) {
            LOG.info("Ask 3: " + orderBook.getAsks().get(2).getLimitPrice() + " volume " + orderBook.getAsks().get(2).getOriginalAmount());
            LOG.info("Ask 2: " + orderBook.getAsks().get(1).getLimitPrice() + " volume " + orderBook.getAsks().get(1).getOriginalAmount());
            LOG.info("Ask 1: " + orderBook.getAsks().get(0).getLimitPrice() + " volume " + orderBook.getAsks().get(0).getOriginalAmount());
            LOG.info("--");
            LOG.info("Bid 1: " + orderBook.getBids().get(0).getLimitPrice() + " volume " + orderBook.getBids().get(0).getOriginalAmount());
            LOG.info("Bid 2: " + orderBook.getBids().get(1).getLimitPrice() + " volume " + orderBook.getBids().get(1).getOriginalAmount());
            LOG.info("Bid 3: " + orderBook.getBids().get(2).getLimitPrice() + " volume " + orderBook.getBids().get(2).getOriginalAmount());
            LOG.info("=================");
        }
    });
    while (true) {
        TimeUnit.SECONDS.sleep(60);
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable) StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 22 with CurrencyPair

use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.

the class CoinjarStreamingMarketDataServiceIntegration method runTestUsdcAud.

@Test
public void runTestUsdcAud() {
    ExchangeSpecification defaultExchangeSpecification = new ExchangeSpecification(CoinjarStreamingExchange.class);
    StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(defaultExchangeSpecification);
    exchange.connect().blockingAwait();
    StreamingMarketDataService streamingMarketDataService = exchange.getStreamingMarketDataService();
    Disposable usdtOrderBookDisposable = streamingMarketDataService.getOrderBook(new CurrencyPair(Currency.USDC, Currency.AUD)).test().awaitCount(10).assertNoErrors();
    usdtOrderBookDisposable.dispose();
}
Also used : Disposable(io.reactivex.disposables.Disposable) StreamingMarketDataService(info.bitrich.xchangestream.core.StreamingMarketDataService) StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Example 23 with CurrencyPair

use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.

the class ExchangeMetaDataIntegration method testLtcBtcPairMetaData.

@Test
public void testLtcBtcPairMetaData() {
    CurrencyPairMetaData pairMetaData = metaData.getCurrencyPairs().get(new CurrencyPair("LTC/BTC"));
    assertThat(pairMetaData.getPriceScale()).isEqualByComparingTo(6);
    assertThat(pairMetaData.getMinimumAmount()).isEqualByComparingTo("0.01");
    assertThat(pairMetaData.getMaximumAmount().longValueExact()).isEqualTo(100000);
    assertThat(pairMetaData.getAmountStepSize()).isEqualByComparingTo("0.01");
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Example 24 with CurrencyPair

use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.

the class AccountServiceIntegration method testMetaData.

@Test
public void testMetaData() throws Exception {
    Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchange.getExchangeMetaData().getCurrencyPairs();
    Map<Currency, CurrencyMetaData> currencies = exchange.getExchangeMetaData().getCurrencies();
    CurrencyPair currPair;
    Currency curr;
    currPair = currencyPairs.keySet().stream().filter(cp -> "ETH/BTC".equals(cp.toString())).collect(StreamUtils.singletonCollector());
    Assert.assertNotNull(currPair);
    curr = currencies.keySet().stream().filter(c -> Currency.BTC.equals(c)).collect(StreamUtils.singletonCollector());
    Assert.assertNotNull(curr);
    Assert.assertNotNull(curr);
}
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) Test(org.junit.Test)

Example 25 with CurrencyPair

use of org.knowm.xchange.currency.CurrencyPair in project XChange by knowm.

the class MarketDataServiceResilienceTest method shouldSucceedIfFirstCallTimeoutedAndRetryIsEnabled.

@Test
public void shouldSucceedIfFirstCallTimeoutedAndRetryIsEnabled() throws Exception {
    // given
    MarketDataService service = createExchangeWithRetryEnabled().getMarketDataService();
    stubForTicker24WithFirstCallTimetoutAndSecondSuccessful();
    // when
    Ticker ticker = service.getTicker(new CurrencyPair("BNB", "BTC"));
    // then
    assertThat(ticker.getLast()).isEqualByComparingTo("4.00000200");
}
Also used : MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService) Ticker(org.knowm.xchange.dto.marketdata.Ticker) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test) AbstractResilienceTest(org.knowm.xchange.binance.AbstractResilienceTest)

Aggregations

CurrencyPair (org.knowm.xchange.currency.CurrencyPair)518 BigDecimal (java.math.BigDecimal)157 Test (org.junit.Test)125 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)121 Date (java.util.Date)108 ArrayList (java.util.ArrayList)107 Ticker (org.knowm.xchange.dto.marketdata.Ticker)91 Currency (org.knowm.xchange.currency.Currency)88 OrderType (org.knowm.xchange.dto.Order.OrderType)81 Exchange (org.knowm.xchange.Exchange)76 Order (org.knowm.xchange.dto.Order)70 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)60 MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)58 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)57 UserTrade (org.knowm.xchange.dto.trade.UserTrade)57 List (java.util.List)54 HashMap (java.util.HashMap)53 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)53 UserTrades (org.knowm.xchange.dto.trade.UserTrades)51 IOException (java.io.IOException)43