// Interested in the public polling market data feed (no authentication)
bitcoiniumMarketDataService = (BitcoiniumMarketDataServiceRaw) bitcoiniumExchange.getPollingMarketDataService();
// Setup the panel
final XChartPanel chartPanel = buildPanel();
// Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// Create and set up the window.
JFrame frame = new JFrame("XChart");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(chartPanel);
// Display the window.
frame.pack();
frame.setVisible(true);
}
});
// Simulate a data feed
TimerTask chartUpdaterTask = new TimerTask() {
@Override
public void run() {
try {
BitcoiniumTicker bitcoiniumTicker = bitcoiniumMarketDataService.getBitcoiniumTicker(Currencies.BTC, "BITSTAMP_USD");
System.out.println(bitcoiniumTicker.toString());
Date timestamp = new Date(bitcoiniumTicker.getTimestamp());
float price = bitcoiniumTicker.getLast().floatValue();
if (xAxisData.get(xAxisData.size() - 1).getTime() != timestamp.getTime()) {
xAxisData.add(timestamp);
yAxisData.add(price);
Series series = chartPanel.updateSeries(SERIES_NAME, xAxisData, yAxisData);
System.out.println(series.getXData());
System.out.println(series.getYData());
}
else {
System.out.println("No new data.");