BitcoiniumMarketDataServiceRaw bitcoiniumMarketDataService = (BitcoiniumMarketDataServiceRaw) bitcoiniumExchange.getPollingMarketDataService();
System.out.println("fetching data...");
// Get the latest order book data for BTC/USD - BITSTAMP
BitcoiniumOrderbook bitcoiniumOrderbook = bitcoiniumMarketDataService.getBitcoiniumOrderbook(Currencies.BTC, "BITSTAMP_USD", "TEN_PERCENT");
System.out.println("Order book: " + bitcoiniumOrderbook);
System.out.println("received data.");
System.out.println("plotting...");
// Create Chart
Chart chart = new Chart(800, 500);
// Customize Chart
chart.setChartTitle("Bitcoinium Order Book - BITSTAMP_BTC_USD");
chart.setYAxisTitle("BTC");
chart.setXAxisTitle("USD");
chart.getStyleManager().setChartType(ChartType.Area);
// BIDS
// Collections.reverse(bitcoiniumOrderbook.getBidPriceList());
// Collections.reverse(bitcoiniumOrderbook.getBidVolumeList());
// Bids Series
List<Float> bidsPriceData = getPriceData(bitcoiniumOrderbook.getBids());
Collections.reverse(bidsPriceData);
List<Float> bidsVolumeData = getVolumeData(bitcoiniumOrderbook.getBids());
Collections.reverse(bidsVolumeData);
Series series = chart.addSeries("bids", bidsPriceData, bidsVolumeData);
series.setMarker(SeriesMarker.NONE);
// ASKS
// Asks Series
series = chart.addSeries("asks", getPriceData(bitcoiniumOrderbook.getAsks()), getVolumeData(bitcoiniumOrderbook.getAsks()));
series.setMarker(SeriesMarker.NONE);
new SwingWrapper(chart).displayChart();
}