use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class ZaifAdaptersTest method testFullBookAdapter.
@Test
public void testFullBookAdapter() throws IOException {
// Read in the JSON from the example resources
InputStream is = ZaifAdaptersTest.class.getResourceAsStream("/org/knowm/xchange/zaif/marketdata/example-fullbook-data.json");
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
ZaifFullBook zaifFullBook = mapper.readValue(is, ZaifFullBook.class);
OrderBook orderBook = ZaifAdapters.adaptOrderBook(zaifFullBook, CurrencyPair.BTC_JPY);
assertThat(orderBook.getBids().get(0).getCurrencyPair()).isEqualTo(CurrencyPair.BTC_JPY);
assertThat(orderBook.getBids().get(0).getLimitPrice()).isEqualTo("934920");
assertThat(orderBook.getBids().get(0).getOriginalAmount()).isEqualTo("0.03");
assertThat(orderBook.getAsks().get(0).getLimitPrice()).isEqualTo("935355");
assertThat(orderBook.getAsks().get(0).getOriginalAmount()).isEqualTo("0.02");
}
use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class MarketDataFetchIntegration method depthFetchTest.
@Test
public void depthFetchTest() throws Exception {
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(ZaifExchange.class);
MarketDataService marketDataService = exchange.getMarketDataService();
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_JPY);
System.out.println(orderBook.toString());
assertThat(orderBook).isNotNull();
}
use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class YoBitMarketDataService method getOrderBooks.
public Iterable<OrderBook> getOrderBooks(OrderBooksRequestParam params) throws IOException {
if (params instanceof MultiCurrencyOrderBooksRequestParams) {
MultiCurrencyOrderBooksRequestParams booksRequestParam = (MultiCurrencyOrderBooksRequestParams) params;
List<OrderBook> res = new ArrayList<>();
YoBitOrderBooksReturn orderBooks = getOrderBooks(booksRequestParam.currencyPairs, booksRequestParam.desiredDepth);
for (String ccyPair : orderBooks.orderBooks.keySet()) {
CurrencyPair currencyPair = YoBitAdapters.adaptCurrencyPair(ccyPair);
OrderBook orderBook = YoBitAdapters.adaptOrderBook(orderBooks.orderBooks.get(ccyPair), currencyPair);
res.add(orderBook);
}
return res;
}
throw new IllegalStateException("Don't understand " + params);
}
use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class MarketDataServiceIntegration method testGetAllOrderBooks.
@Test
public void testGetAllOrderBooks() throws Exception {
BiboxMarketDataService marketDataService = (BiboxMarketDataService) BIBOX.getMarketDataService();
List<OrderBook> orderBooks = marketDataService.getAllOrderBooks(200);
assertThat(orderBooks.size()).isGreaterThan(20);
}
use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class BTCMarketsMarketDataServiceTest method shouldGetOrderBook.
@Test
public void shouldGetOrderBook() throws IOException {
// given
final LimitOrder[] expectedAsks = expectedAsks();
final LimitOrder[] expectedBids = expectedBids();
BTCMarketsOrderBook orderBookMock = parse("org/knowm/xchange/btcmarkets/dto/" + "ShortOrderBook", BTCMarketsOrderBook.class);
when(btcMarkets.getOrderBook("BTC", "AUD")).thenReturn(orderBookMock);
// when
OrderBook orderBook = btcMarketsMarketDataService.getOrderBook(CurrencyPair.BTC_AUD);
// then
assertThat(orderBook.getTimeStamp().getTime()).isEqualTo(1442997827000L);
List<LimitOrder> asks = orderBook.getAsks();
assertThat(asks).hasSize(3);
for (int i = 0; i < asks.size(); i++) {
BtcMarketsAssert.assertEquals(asks.get(i), expectedAsks[i]);
}
List<LimitOrder> bids = orderBook.getBids();
assertThat(bids).hasSize(2);
for (int i = 0; i < bids.size(); i++) {
BtcMarketsAssert.assertEquals(bids.get(i), expectedBids[i]);
}
}
Aggregations