public void start() throws ExecutionException, InterruptedException { // Use the default MtGox settings Exchange mtGoxExchange = ExchangeFactory.INSTANCE.createExchange(MtGoxExchange.class.getName()); // Configure BTC/USD ticker stream for MtGox ExchangeStreamingConfiguration btcusdConfiguration = new MtGoxStreamingConfiguration(10, 10000, Currencies.BTC, Currencies.USD, false); // Interested in the public streaming market data feed (no authentication) StreamingExchangeService btcusdStreamingMarketDataService = mtGoxExchange.getStreamingExchangeService(btcusdConfiguration); // Requesting initial order book using the polling service PollingMarketDataService marketDataService = mtGoxExchange.getPollingMarketDataService(); MarketDataRunnable.book = marketDataService.getPartialOrderBook(Currencies.BTC, Currencies.USD); // Open the connections to the exchange btcusdStreamingMarketDataService.connect(); ExecutorService executorService = Executors.newSingleThreadExecutor(); Future<?> mtGoxMarketDataFuture = executorService.submit(new MarketDataRunnable(btcusdStreamingMarketDataService)); // the thread waits here until the Runnable is done. mtGoxMarketDataFuture.get(); executorService.shutdown(); // Disconnect and exit System.out.println(Thread.currentThread().getName() + ": Disconnecting..."); btcusdStreamingMarketDataService.disconnect(); }