use of org.knowm.xchange.kraken.dto.marketdata.results.KrakenDepthResult in project XChange by knowm.
the class KrakenDepthJSONTest method testUnmarshal.
@Test
public void testUnmarshal() throws IOException {
// Read in the JSON from the example resources
InputStream is = KrakenDepthJSONTest.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();
// Verify that the example data was unmarshalled correctly
assertThat(krakenDepths.get("XXBTXLTC")).isEqualTo(null);
List<KrakenPublicOrder> krakenAsks = krakenDepths.get("XXBTZEUR").getAsks();
KrakenPublicOrder krakenPublicOrder = krakenAsks.get(0);
assertThat(krakenPublicOrder.getPrice()).isEqualTo(new BigDecimal("530.75513"));
assertThat(krakenPublicOrder.getVolume()).isEqualTo(new BigDecimal("0.248"));
assertThat(krakenPublicOrder.getTimestamp()).isEqualTo(1391825343L);
}
use of org.knowm.xchange.kraken.dto.marketdata.results.KrakenDepthResult 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.results.KrakenDepthResult in project XChange by knowm.
the class KrakenMarketDataServiceRaw method getKrakenDepth.
public KrakenDepth getKrakenDepth(CurrencyPair currencyPair, long count) throws IOException {
String krakenCurrencyPair = KrakenUtils.createKrakenCurrencyPair(currencyPair);
KrakenDepthResult result = kraken.getDepth(krakenCurrencyPair, count);
return checkResult(result).get(krakenCurrencyPair);
}
Aggregations