Search in sources :

Example 26 with ExchangeSpecification

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

the class CoinbaseProStreamingExchangeTest method testOverrideWebsocketApiUri.

@Test
public void testOverrideWebsocketApiUri() {
    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, false);
    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)

Example 27 with ExchangeSpecification

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

the class CoinbaseProStreamingExchangeTest method testWhenUsingSandboxWithPrime.

@Test
public void testWhenUsingSandboxWithPrime() {
    final String primeSandboxApiUri = "wss://ws-feed-public.sandbox.exchange.coinbase.com";
    final CoinbaseProStreamingExchange coinbaseProStreamingExchange = new CoinbaseProStreamingExchange();
    final ExchangeSpecification sandboxExchangeSpecification = coinbaseProStreamingExchange.getDefaultExchangeSpecification();
    sandboxExchangeSpecification.setExchangeSpecificParametersItem(Parameters.PARAM_USE_SANDBOX, true);
    sandboxExchangeSpecification.setExchangeSpecificParametersItem(Parameters.PARAM_USE_PRIME, true);
    sandboxExchangeSpecification.setShouldLoadRemoteMetaData(false);
    final CoinbaseProStreamingExchange exchange = (CoinbaseProStreamingExchange) StreamingExchangeFactory.INSTANCE.createExchange(sandboxExchangeSpecification);
    assertThat(exchange.getApiUri()).isEqualTo(primeSandboxApiUri);
    assertThat(exchange.getExchangeSpecification().getOverrideWebsocketApiUri()).isEqualTo(null);
}
Also used : ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) Test(org.junit.Test)

Example 28 with ExchangeSpecification

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

the class BinanceUsExchangeIntegration method createExchange.

protected static void createExchange() throws Exception {
    exchange = ExchangeFactory.INSTANCE.createExchangeWithoutSpecification(BinanceUsExchange.class);
    ExchangeSpecification spec = exchange.getDefaultExchangeSpecification();
    boolean useSandbox = Boolean.parseBoolean(System.getProperty(BinanceExchange.SPECIFIC_PARAM_USE_SANDBOX, Boolean.FALSE.toString()));
    spec.setExchangeSpecificParametersItem(BinanceExchange.SPECIFIC_PARAM_USE_SANDBOX, useSandbox);
    exchange.applySpecification(spec);
}
Also used : BinanceUsExchange(org.knowm.xchange.binance.BinanceUsExchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification)

Example 29 with ExchangeSpecification

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

the class BinanceExchangeIntegration method createExchangeMocked.

protected BinanceExchange createExchangeMocked() {
    BinanceExchange exchangeMocked = ExchangeFactory.INSTANCE.createExchangeWithoutSpecification(BinanceExchange.class);
    ExchangeSpecification specification = exchangeMocked.getDefaultExchangeSpecification();
    specification.setHost("localhost");
    specification.setSslUri("http://localhost:" + wireMockRule.port() + "/");
    specification.setPort(wireMockRule.port());
    specification.setShouldLoadRemoteMetaData(false);
    exchangeMocked.applySpecification(specification);
    return exchangeMocked;
}
Also used : ExchangeSpecification(org.knowm.xchange.ExchangeSpecification)

Example 30 with ExchangeSpecification

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

the class BinanceExchangeIntegration method createExchange.

protected static void createExchange() throws Exception {
    exchange = ExchangeFactory.INSTANCE.createExchangeWithoutSpecification(BinanceExchange.class);
    ExchangeSpecification spec = exchange.getDefaultExchangeSpecification();
    boolean useSandbox = Boolean.parseBoolean(System.getProperty(BinanceExchange.SPECIFIC_PARAM_USE_SANDBOX, Boolean.FALSE.toString()));
    spec.setExchangeSpecificParametersItem(BinanceExchange.SPECIFIC_PARAM_USE_SANDBOX, useSandbox);
    exchange.applySpecification(spec);
}
Also used : ExchangeSpecification(org.knowm.xchange.ExchangeSpecification)

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