use of org.knowm.xchange.bitcoinium.service.BitcoiniumMarketDataServiceRaw in project XChange by knowm.
the class BitcoiniumMarketDataDemo method raw.
private static void raw(Exchange exchange) throws IOException {
// Interested in the public market data feed (no authentication)
BitcoiniumMarketDataServiceRaw bitcoiniumSpecificMarketDataService = (BitcoiniumMarketDataServiceRaw) exchange.getMarketDataService();
// Get the latest ticker data showing BTC to USD
BitcoiniumTicker bitcoiniumTicker = bitcoiniumSpecificMarketDataService.getBitcoiniumTicker("BTC", "BITSTAMP_USD");
System.out.println("Last: " + bitcoiniumTicker.getLast());
System.out.println("Bid: " + bitcoiniumTicker.getBid());
System.out.println("Ask: " + bitcoiniumTicker.getAsk());
System.out.println("Volume: " + bitcoiniumTicker.getVolume());
// Get the latest order book data for BTC/USD - MtGox
BitcoiniumOrderbook bitcoiniumOrderbook = bitcoiniumSpecificMarketDataService.getBitcoiniumOrderbook("BTC", "BITSTAMP_USD", "TEN_PERCENT");
System.out.println("Order book: " + bitcoiniumOrderbook);
}
use of org.knowm.xchange.bitcoinium.service.BitcoiniumMarketDataServiceRaw in project XChange by knowm.
the class BitcoiniumTickerHistoryDemo method main.
public static void main(String[] args) throws Exception {
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(BitcoiniumExchange.class);
// exchangeSpecification.setPlainTextUri("http://openexchangerates.org");
exchangeSpecification.setApiKey("42djci5kmbtyzrvglfdw3e2dgmh5mr37");
System.out.println(exchangeSpecification.toString());
Exchange bitcoiniumExchange = ExchangeFactory.INSTANCE.createExchange(exchangeSpecification);
// Interested in the public market data feed (no authentication)
BitcoiniumMarketDataServiceRaw bitcoiniumMarketDataService = (BitcoiniumMarketDataServiceRaw) bitcoiniumExchange.getMarketDataService();
System.out.println("fetching data...");
// Get the latest order book data for BTC/USD - BITSTAMP
BitcoiniumTickerHistory bitcoiniumTickerHistory = bitcoiniumMarketDataService.getBitcoiniumTickerHistory("BTC", "BITSTAMP_USD", "THIRTY_DAYS");
System.out.println(bitcoiniumTickerHistory.toString());
List<Date> xAxisData = new ArrayList<>();
List<Float> yAxisData = new ArrayList<>();
for (int i = 0; i < bitcoiniumTickerHistory.getCondensedTickers().length; i++) {
BitcoiniumTicker bitcoiniumTicker = bitcoiniumTickerHistory.getCondensedTickers()[i];
Date timestamp = new Date(bitcoiniumTicker.getTimestamp());
float price = bitcoiniumTicker.getLast().floatValue();
System.out.println(timestamp + ": " + price);
xAxisData.add(timestamp);
yAxisData.add(price);
}
// Create Chart
XYChart chart = new XYChartBuilder().width(800).height(600).title("Bitstamp Price vs. Date").xAxisTitle("Date").yAxisTitle("Price").build();
// Customize Chart
chart.getStyler().setLegendPosition(LegendPosition.InsideNE);
chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Area);
XYSeries series = chart.addSeries("Bitcoinium USD/BTC", xAxisData, yAxisData);
series.setMarker(SeriesMarkers.NONE);
new SwingWrapper(chart).displayChart();
}
use of org.knowm.xchange.bitcoinium.service.BitcoiniumMarketDataServiceRaw in project XChange by knowm.
the class BitcoiniumOrderBookChartDemo method main.
public static void main(String[] args) throws Exception {
ExchangeSpecification exchangeSpecification = new ExchangeSpecification(BitcoiniumExchange.class);
// exchangeSpecification.setPlainTextUri("http://openexchangerates.org");
exchangeSpecification.setApiKey("42djci5kmbtyzrvglfdw3e2dgmh5mr37");
System.out.println(exchangeSpecification.toString());
Exchange bitcoiniumExchange = ExchangeFactory.INSTANCE.createExchange(exchangeSpecification);
// Interested in the public market data feed (no authentication)
BitcoiniumMarketDataServiceRaw bitcoiniumMarketDataService = (BitcoiniumMarketDataServiceRaw) bitcoiniumExchange.getMarketDataService();
System.out.println("fetching data...");
// Get the latest order book data for BTC/USD - BITSTAMP
BitcoiniumOrderbook bitcoiniumOrderbook = bitcoiniumMarketDataService.getBitcoiniumOrderbook("BTC", "BITSTAMP_USD", "TEN_PERCENT");
System.out.println("Order book: " + bitcoiniumOrderbook);
System.out.println("received data.");
System.out.println("plotting...");
// Create Chart
XYChart chart = new XYChartBuilder().width(800).height(600).title("Bitcoinium Order Book - BITSTAMP_BTC_USD").xAxisTitle("BTC").yAxisTitle("USD").build();
// Customize Chart
chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.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);
XYSeries series = chart.addSeries("bids", bidsPriceData, bidsVolumeData);
series.setMarker(SeriesMarkers.NONE);
// ASKS
// Asks Series
series = chart.addSeries("asks", getPriceData(bitcoiniumOrderbook.getAsks()), getVolumeData(bitcoiniumOrderbook.getAsks()));
series.setMarker(SeriesMarkers.NONE);
new SwingWrapper(chart).displayChart();
}
Aggregations