use of org.knowm.xchange.quoine.dto.marketdata.QuoineOrderBook in project XChange by knowm.
the class QuoineAdaptersTest method testAdaptOrderBook.
@Test
public void testAdaptOrderBook() throws IOException {
// Read in the JSON from the example resources
InputStream is = QuoineOrderBookJSONTest.class.getResourceAsStream("/org/knowm/xchange/quoine/dto/marketdata/example-depth-data.json");
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
QuoineOrderBook quoineOrderBook = mapper.readValue(is, QuoineOrderBook.class);
OrderBook orderBook = QuoineAdapters.adaptOrderBook(quoineOrderBook, CurrencyPair.BTC_USD);
// Verify that the example data was unmarshalled correctly
assertThat(orderBook.getAsks().size()).isEqualTo(20);
assertThat(orderBook.getBids().size()).isEqualTo(20);
assertThat(orderBook.getBids().get(0).getId()).isEqualTo("");
assertThat(orderBook.getBids().get(0).getLimitPrice()).isEqualTo(new BigDecimal("226.69718"));
}
use of org.knowm.xchange.quoine.dto.marketdata.QuoineOrderBook in project XChange by knowm.
the class OrderBookDemo method raw.
private static void raw(Exchange quoineExchange) throws IOException {
// Interested in the public market data feed (no authentication)
QuoineMarketDataServiceRaw quoineMarketDataService = (QuoineMarketDataServiceRaw) quoineExchange.getMarketDataService();
// Get the latest order book data
QuoineOrderBook quoineOrderBook = quoineMarketDataService.getOrderBook(1);
System.out.println(quoineOrderBook.toString());
System.out.println("size: " + (quoineOrderBook.getSellPriceLevels().size() + quoineOrderBook.getBuyPriceLevels().size()));
}
Aggregations