Search in sources :

Example 21 with ExchangeSpecification

use of org.knowm.xchange.ExchangeSpecification 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 22 with ExchangeSpecification

use of org.knowm.xchange.ExchangeSpecification 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 23 with ExchangeSpecification

use of org.knowm.xchange.ExchangeSpecification 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 24 with ExchangeSpecification

use of org.knowm.xchange.ExchangeSpecification 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)

Example 25 with ExchangeSpecification

use of org.knowm.xchange.ExchangeSpecification in project XChange by knowm.

the class CoinbaseProStreamingExchangeTest method testOverrideWebsocketApiUriWhenUsingPrime.

@Test
public void testOverrideWebsocketApiUriWhenUsingPrime() {
    final String overrideWebsocketApiUri = "wss://demo.websocket.com";
    final CoinbaseProStreamingExchange coinbaseProStreamingExchange = new CoinbaseProStreamingExchange();
    final ExchangeSpecification sandboxExchangeSpecification = coinbaseProStreamingExchange.getDefaultExchangeSpecification();
    sandboxExchangeSpecification.setExchangeSpecificParametersItem(Parameters.PARAM_USE_SANDBOX, false);
    sandboxExchangeSpecification.setExchangeSpecificParametersItem(Parameters.PARAM_USE_PRIME, true);
    sandboxExchangeSpecification.setOverrideWebsocketApiUri(overrideWebsocketApiUri);
    sandboxExchangeSpecification.setShouldLoadRemoteMetaData(false);
    final CoinbaseProStreamingExchange exchange = (CoinbaseProStreamingExchange) StreamingExchangeFactory.INSTANCE.createExchange(sandboxExchangeSpecification);
    assertThat(exchange.getApiUri()).isEqualTo(overrideWebsocketApiUri);
    assertThat(exchange.getExchangeSpecification().getOverrideWebsocketApiUri()).isEqualTo(overrideWebsocketApiUri);
}
Also used : ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) Test(org.junit.Test)

Aggregations

ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)327 Exchange (org.knowm.xchange.Exchange)93 Test (org.junit.Test)66 IOException (java.io.IOException)22 MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)20 StreamingExchange (info.bitrich.xchangestream.core.StreamingExchange)17 BigDecimal (java.math.BigDecimal)16 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)16 Before (org.junit.Before)15 CoinsuperExchange (org.knowm.xchange.coinsuper.CoinsuperExchange)15 TradeService (org.knowm.xchange.service.trade.TradeService)14 Disposable (io.reactivex.disposables.Disposable)12 ProductSubscription (info.bitrich.xchangestream.core.ProductSubscription)11 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)9 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)9 Ticker (org.knowm.xchange.dto.marketdata.Ticker)8 OkCoinExchange (org.knowm.xchange.okcoin.OkCoinExchange)7 BitcoiniumExchange (org.knowm.xchange.bitcoinium.BitcoiniumExchange)6 CoinfloorExchange (org.knowm.xchange.coinfloor.CoinfloorExchange)6 DVChainExchange (org.knowm.xchange.dvchain.DVChainExchange)6