use of org.knowm.xchange.bitcoinium.dto.marketdata.BitcoiniumTickerHistory in project XChange by knowm.
the class BitcoiniumMarketDataServiceRaw method getBitcoiniumTickerHistory.
/**
* @param tradableIdentifier
* @param currency
* @param timeWindow - The time period of the requested ticker data. Value can be from set: {
* "10m", "1h", "3h", "12h", "24h", "3d", "7d", "30d", "2M" }
* @return
* @throws IOException
*/
public BitcoiniumTickerHistory getBitcoiniumTickerHistory(String tradableIdentifier, String currency, String timeWindow) throws IOException {
String pair = BitcoiniumUtils.createCurrencyPairString(tradableIdentifier, currency);
verifyTimeWindow(timeWindow);
// Request data
BitcoiniumTickerHistory bitcoiniumTickerHistory = bitcoinium.getTickerHistory(pair, timeWindow, exchange.getExchangeSpecification().getApiKey());
return bitcoiniumTickerHistory;
}
use of org.knowm.xchange.bitcoinium.dto.marketdata.BitcoiniumTickerHistory in project XChange by knowm.
the class BitcoiniumRealtimeTickerDemo method buildPanel.
public XChartPanel<XYChart> buildPanel() throws IOException {
System.out.println("fetching data...");
// Get the latest order book data for BTC/USD - BITSTAMP
BitcoiniumTickerHistory bitcoiniumTickerHistory = bitcoiniumMarketDataService.getBitcoiniumTickerHistory("BTC", "BITSTAMP_USD", "THREE_HOURS");
System.out.println(bitcoiniumTickerHistory.toString());
// build ticker history chart series data
xAxisData = new ArrayList<>();
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
chart = new XYChartBuilder().width(800).height(600).title("Real-time Bitstamp Price vs. Time").xAxisTitle("Time").yAxisTitle("Price").build();
// Customize Chart
chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Area);
chart.getStyler().setLegendPosition(LegendPosition.InsideNE);
// add series
XYSeries series = chart.addSeries(SERIES_NAME, xAxisData, yAxisData);
series.setMarker(SeriesMarkers.NONE);
return new XChartPanel(chart);
}
use of org.knowm.xchange.bitcoinium.dto.marketdata.BitcoiniumTickerHistory 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();
}
Aggregations