Search in sources :

Example 1 with QuoineOrderBook

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"));
}
Also used : QuoineOrderBook(org.knowm.xchange.quoine.dto.marketdata.QuoineOrderBook) OrderBook(org.knowm.xchange.dto.marketdata.OrderBook) QuoineOrderBook(org.knowm.xchange.quoine.dto.marketdata.QuoineOrderBook) InputStream(java.io.InputStream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BigDecimal(java.math.BigDecimal) QuoineOrderBookJSONTest(org.knowm.xchange.quoine.dto.marketdata.QuoineOrderBookJSONTest) QuoineWalletJSONTest(org.knowm.xchange.quoine.dto.account.QuoineWalletJSONTest) Test(org.junit.Test) QuoineTickerJSONTest(org.knowm.xchange.quoine.dto.marketdata.QuoineTickerJSONTest) QuoineOrdersListJSONTest(org.knowm.xchange.quoine.dto.trade.QuoineOrdersListJSONTest)

Example 2 with QuoineOrderBook

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()));
}
Also used : QuoineMarketDataServiceRaw(org.knowm.xchange.quoine.service.QuoineMarketDataServiceRaw) QuoineOrderBook(org.knowm.xchange.quoine.dto.marketdata.QuoineOrderBook)

Aggregations

QuoineOrderBook (org.knowm.xchange.quoine.dto.marketdata.QuoineOrderBook)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InputStream (java.io.InputStream)1 BigDecimal (java.math.BigDecimal)1 Test (org.junit.Test)1 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)1 QuoineWalletJSONTest (org.knowm.xchange.quoine.dto.account.QuoineWalletJSONTest)1 QuoineOrderBookJSONTest (org.knowm.xchange.quoine.dto.marketdata.QuoineOrderBookJSONTest)1 QuoineTickerJSONTest (org.knowm.xchange.quoine.dto.marketdata.QuoineTickerJSONTest)1 QuoineOrdersListJSONTest (org.knowm.xchange.quoine.dto.trade.QuoineOrdersListJSONTest)1 QuoineMarketDataServiceRaw (org.knowm.xchange.quoine.service.QuoineMarketDataServiceRaw)1