Search in sources :

Example 1 with LocalExchangeConfig

use of info.bitrich.xchangestream.util.LocalExchangeConfig in project XChange by knowm.

the class BitmexOrderIT method setup.

@Before
public void setup() throws IOException {
    LocalExchangeConfig localConfig = PropsLoader.loadKeys("bitmex.secret.keys", "bitmex.secret.keys.origin", "bitmex");
    exchange = (BitmexStreamingExchange) StreamingExchangeFactory.INSTANCE.createExchange(BitmexStreamingExchange.class);
    exchange.applySpecification(BitmexTestsCommons.getExchangeSpecification(localConfig, exchange.getDefaultExchangeSpecification()));
    exchange.connect().blockingAwait();
    xbtUsd = exchange.determineActiveContract(CurrencyPair.XBT_USD.base.toString(), CurrencyPair.XBT_USD.counter.toString(), PERPETUAL);
    BitmexMarketDataService marketDataService = (BitmexMarketDataService) exchange.getMarketDataService();
    OrderBook orderBook = marketDataService.getOrderBook(xbtUsd);
    List<LimitOrder> asks = orderBook.getAsks();
    // todo : for the streaming service best ask is at 0 pos
    BigDecimal topPriceAsk = getPrice(asks, asks.size() - 1);
    BigDecimal topPriceBid = getPrice(orderBook.getBids(), 0);
    LOG.info("Got best ask = {}, best bid = {}", topPriceAsk, topPriceBid);
    Assert.assertTrue("Got empty order book", topPriceAsk != null || topPriceBid != null);
    testAskPrice = topPriceAsk;
    testBidPrice = topPriceBid;
    tradeService = (BitmexTradeService) exchange.getTradeService();
}
Also used : BitmexMarketDataService(org.knowm.xchange.bitmex.service.BitmexMarketDataService) OrderBook(org.knowm.xchange.dto.marketdata.OrderBook) LocalExchangeConfig(info.bitrich.xchangestream.util.LocalExchangeConfig) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal) Before(org.junit.Before)

Example 2 with LocalExchangeConfig

use of info.bitrich.xchangestream.util.LocalExchangeConfig in project XChange by knowm.

the class BitmexWithProxyIT method setup.

@Before
public void setup() throws Exception {
    String execLine = PropsLoader.proxyExecLine();
    LOG.info("Running proxy with \"{}\" command", execLine);
    proxyUtil = new ProxyUtil(execLine, 5000);
    proxyUtil.startProxy();
    LocalExchangeConfig localConfig = PropsLoader.loadKeys("bitmex.secret.keys", "bitmex.secret.keys.origin", "bitmex");
    exchange = StreamingExchangeFactory.INSTANCE.createExchange(BitmexStreamingExchange.class);
    ExchangeSpecification exchangeSpecification = BitmexTestsCommons.getExchangeSpecification(localConfig, exchange.getDefaultExchangeSpecification());
    exchangeSpecification.setExchangeSpecificParametersItem(StreamingExchange.SOCKS_PROXY_HOST, "localhost");
    exchangeSpecification.setExchangeSpecificParametersItem(StreamingExchange.SOCKS_PROXY_PORT, 8889);
    exchange.applySpecification(exchangeSpecification);
    exchange.connect().blockingAwait();
}
Also used : ProxyUtil(info.bitrich.xchangestream.util.ProxyUtil) LocalExchangeConfig(info.bitrich.xchangestream.util.LocalExchangeConfig) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) Before(org.junit.Before)

Aggregations

LocalExchangeConfig (info.bitrich.xchangestream.util.LocalExchangeConfig)2 Before (org.junit.Before)2 ProxyUtil (info.bitrich.xchangestream.util.ProxyUtil)1 BigDecimal (java.math.BigDecimal)1 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)1 BitmexMarketDataService (org.knowm.xchange.bitmex.service.BitmexMarketDataService)1 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1