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();
}
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();
}
Aggregations