Search in sources :

Example 1 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange in project XChange by knowm.

the class CoinjarUserTradesExample method runTest.

@Test
public void runTest() {
    ExchangeSpecification defaultExchangeSpecification = new ExchangeSpecification(CoinjarStreamingExchange.class);
    AuthUtils.setApiAndSecretKey(defaultExchangeSpecification);
    if (defaultExchangeSpecification.getApiKey() != null) {
        StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(defaultExchangeSpecification);
        exchange.connect().blockingAwait();
        StreamingTradeService streamingTradeService = exchange.getStreamingTradeService();
        Disposable disposable = streamingTradeService.getUserTrades(null).test().awaitCount(1, BaseTestConsumer.TestWaitStrategy.SLEEP_100MS, 1000 * 60 * 10).assertNoErrors();
        disposable.dispose();
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable) StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) StreamingTradeService(info.bitrich.xchangestream.core.StreamingTradeService) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) Test(org.junit.Test)

Example 2 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange 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 3 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange in project XChange by knowm.

the class CoinmateManualExample method main.

public static void main(String[] args) {
    ExchangeSpecification exSpec = new CoinmateStreamingExchange().getDefaultExchangeSpecification();
    StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(exSpec);
    exchange.connect().blockingAwait();
    exchange.getStreamingMarketDataService().getOrderBook(CurrencyPair.BTC_EUR).subscribe(orderBook -> {
        LOG.info("Ask: {}", orderBook.getAsks().get(0));
        LOG.info("Bid: {}", orderBook.getBids().get(0));
    });
    exchange.getStreamingMarketDataService().getTrades(CurrencyPair.BTC_USD).subscribe(trade -> {
        LOG.info("Trade {}", trade);
    });
    try {
        Thread.sleep(100000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : StreamingExchange(info.bitrich.xchangestream.core.StreamingExchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification)

Example 4 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange 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 5 with StreamingExchange

use of info.bitrich.xchangestream.core.StreamingExchange in project XChange by knowm.

the class CoinjarStreamingMarketDataServiceIntegration method runTestBtcAud.

@Test
public void runTestBtcAud() {
    ExchangeSpecification defaultExchangeSpecification = new ExchangeSpecification(CoinjarStreamingExchange.class);
    StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(defaultExchangeSpecification);
    exchange.connect().blockingAwait();
    StreamingMarketDataService streamingMarketDataService = exchange.getStreamingMarketDataService();
    Disposable btcOrderBookDisposable = streamingMarketDataService.getOrderBook(CurrencyPair.BTC_AUD).test().awaitCount(10).assertNoErrors();
    btcOrderBookDisposable.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) Test(org.junit.Test)

Aggregations

StreamingExchange (info.bitrich.xchangestream.core.StreamingExchange)28 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)16 Disposable (io.reactivex.disposables.Disposable)14 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)7 Test (org.junit.Test)6 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)3 ProductSubscription (info.bitrich.xchangestream.core.ProductSubscription)2 StreamingExchangeFactory (info.bitrich.xchangestream.core.StreamingExchangeFactory)2 StreamingMarketDataService (info.bitrich.xchangestream.core.StreamingMarketDataService)2 StreamingTradeService (info.bitrich.xchangestream.core.StreamingTradeService)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 BigDecimal (java.math.BigDecimal)2 Currency (org.knowm.xchange.currency.Currency)2 USE_REALTIME_BOOK_TICKER (info.bitrich.xchangestream.binance.BinanceStreamingExchange.USE_REALTIME_BOOK_TICKER)1 BitstampStreamingExchange (info.bitrich.xchangestream.bitstamp.v2.BitstampStreamingExchange)1 CexioStreamingExchange (info.bitrich.xchangestream.cexio.CexioStreamingExchange)1 CoinbaseProStreamingExchange (info.bitrich.xchangestream.coinbasepro.CoinbaseProStreamingExchange)1 ArrayList (java.util.ArrayList)1 Ignore (org.junit.Ignore)1 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)1