Messtone LLC Manages(Xchange):Public Market Data.

Messtone Devices Enables public APIs which do not require authentic: Exchange bitstamp=Exchange factory.INSTANCE.createExchange(BitstampExchange.class);MarketDataService marketDataService=bitstamp.getMarketDataService( );Ticker ticker=marketDataService.getTicker(CurrencyPair.BTC_USD); System.out.println(ticker.toString( ));createExchange( ):ExchangeSpecification exSpec=new BitstampExchange( ).getDefaultExchangeSpecification( );exSpec.setUserNameRobertHarper(“34387”);exSpec.setApiKey(“a4SDmpl9s6xWJS5fkKRT6yn41vXuYOAM”);exSpec.setSecretKey(“sisJixU6XdOd1yr6w02EHCb9UwYzTNuj”);Exchange bitstamp=ExchangeFactory.INSTANCE.createExchange(exSpec);TradeService,can be used to access private data://GET the account information AccountService accountService=bitstamp.getAccuntService( );AccountInfo accountInfo=accountIService.getAccountInfo( );System.out.println(accountInfo.toString( ));//use StreamingExchangeFactory instead of ExchangeFactory StreamingExchange exchange=StreamingExchangeFactory.INSTANCE.createExchange(ButstampStreamingExhange .class);//Connect to the Exchange Websocket API.Here we use a blocking wait.exchange.connect( ).BlockingAwait( );//Subscribe to live trades disposable subscription1 = exchange.getStreamingMarketDataService( ).getTrades(CurrencyPair.BTC_USD).subscribe(trade->LOGG.info(“Trade:{ }”,trade),throwable ->LOG.error(“Error in trade subscription”,throwable));//Subscribe order book data with the references to the subscription.Disposable subscription2 = exchange.getStreamingMarketDataService( ).getOrderBook(CurrencyPair.BTC_USD).subscribe(orderBook->LOC.info(“Order book:{ }”,orderBook));//Wait a while to see some results arrive Thread.sleep(20000);Unsubscribe subscription1.dispose( ); subscription2.dispose( );//Disconnect from exchange(blocking again) exchange.disconnect( ).blockingAwait( );

Leave a comment