use of org.knowm.xchange.kraken.dto.marketdata.KrakenDepth in project XChange by knowm.
the class KrakenDepthDemo method raw.
private static void raw(Exchange krakenExchange) throws IOException {
// Interested in the public market data feed (no authentication)
KrakenMarketDataServiceRaw krakenMarketDataService = (KrakenMarketDataServiceRaw) krakenExchange.getMarketDataService();
// Get the latest full order book data
KrakenDepth depth = krakenMarketDataService.getKrakenDepth(CurrencyPair.BTC_EUR, Long.MAX_VALUE);
System.out.println(depth.toString());
System.out.println("size: " + (depth.getAsks().size() + depth.getBids().size()));
// Get the latest partial size order book data
depth = krakenMarketDataService.getKrakenDepth(CurrencyPair.BTC_EUR, 3L);
System.out.println(depth.toString());
System.out.println("size: " + (depth.getAsks().size() + depth.getBids().size()));
}
use of org.knowm.xchange.kraken.dto.marketdata.KrakenDepth in project XChange by knowm.
the class KrakenAdaptersTest method testAdaptOrderBook.
@Test
public void testAdaptOrderBook() throws JsonParseException, JsonMappingException, IOException {
// Read in the JSON from the example resources
InputStream is = KrakenAdaptersTest.class.getResourceAsStream("/org/knowm/xchange/kraken/dto/marketdata/example-depth-data.json");
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
KrakenDepthResult krakenDepthResult = mapper.readValue(is, KrakenDepthResult.class);
Map<String, KrakenDepth> krakenDepths = krakenDepthResult.getResult();
String krakenAssetPair = "XXBTZEUR";
KrakenDepth krakenDepth = krakenDepths.get(krakenAssetPair);
OrderBook orderBook = KrakenAdapters.adaptOrderBook(krakenDepth, CurrencyPair.BTC_EUR);
List<LimitOrder> asks = orderBook.getAsks();
assertThat(asks.size()).isEqualTo(3);
LimitOrder order = asks.get(0);
assertThat(order.getLimitPrice()).isEqualTo(new BigDecimal("530.75513"));
assertThat(order.getOriginalAmount()).isEqualTo("0.248");
assertThat(order.getTimestamp()).isEqualTo(new Date(1391825343000L));
}
use of org.knowm.xchange.kraken.dto.marketdata.KrakenDepth in project XChange by knowm.
the class KrakenMarketDataService method getOrderBook.
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
long count = Long.MAX_VALUE;
if (args != null && args.length > 0) {
Object arg0 = args[0];
if (arg0 instanceof Long) {
count = (Long) arg0;
} else if (arg0 instanceof Integer) {
count = (Integer) arg0;
} else {
throw new ExchangeException("args[0] must be of type Long or Integer");
}
}
KrakenDepth krakenDepth = getKrakenDepth(currencyPair, count);
return KrakenAdapters.adaptOrderBook(krakenDepth, currencyPair);
}
Aggregations