use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexDepth in project XChange by knowm.
the class BitfinexOrderbookTest method timestampShouldBeInSeconds.
@Test
public void timestampShouldBeInSeconds() {
BitfinexDepth depth = new BitfinexOrderbook(new BitfinexOrderbookLevel[] { new BitfinexOrderbookLevel(ONE, ONE, ONE), new BitfinexOrderbookLevel(ONE, ONE, ONE) }).toBitfinexDepth();
OrderBook orderBook = BitfinexAdapters.adaptOrderBook(depth, BTC_USD);
// What is the time now... after order books created?
assertThat("The timestamp should be a value less than now, but was: " + orderBook.getTimeStamp(), !orderBook.getTimeStamp().after(new Date()));
}
use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexDepth in project XChange by knowm.
the class BitfinexMarketDataService method getOrderBook.
/**
* @param args If two integers are provided, then those count as limit bid and limit ask count
*/
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
try {
// null will cause fetching of full order book, the default behavior in XChange
Integer limitBids = null;
Integer limitAsks = null;
if (args != null && args.length == 2) {
Object arg0 = args[0];
if (!(arg0 instanceof Integer)) {
throw new ExchangeException("Argument 0 must be an Integer!");
} else {
limitBids = (Integer) arg0;
}
Object arg1 = args[1];
if (!(arg1 instanceof Integer)) {
throw new ExchangeException("Argument 1 must be an Integer!");
} else {
limitAsks = (Integer) arg1;
}
}
BitfinexDepth bitfinexDepth = getBitfinexOrderBook(BitfinexUtils.toPairStringV1(currencyPair), limitBids, limitAsks);
OrderBook orderBook = BitfinexAdapters.adaptOrderBook(bitfinexDepth, currencyPair);
return orderBook;
} catch (BitfinexException e) {
throw BitfinexErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexDepth in project XChange by knowm.
the class LendDepthDemo method raw.
private static void raw(BitfinexMarketDataServiceRaw marketDataService) throws IOException {
// Get the latest order book data for USD swaps
BitfinexLendDepth bitfinexDepth = marketDataService.getBitfinexLendBook("USD", 50, 50);
System.out.println("Current Order Book size for USD: " + (bitfinexDepth.getAsks().length + bitfinexDepth.getBids().length));
System.out.println("First Ask: " + bitfinexDepth.getAsks()[0].toString());
System.out.println("First Bid: " + bitfinexDepth.getBids()[0].toString());
System.out.println(bitfinexDepth.toString());
}
use of org.knowm.xchange.bitfinex.v1.dto.marketdata.BitfinexDepth in project XChange by knowm.
the class BitfinexDepthDemo method raw.
private static void raw(BitfinexMarketDataServiceRaw marketDataService) throws IOException {
// Get the latest order book data for BTC/CAD
BitfinexDepth bitfinexDepth = marketDataService.getBitfinexOrderBook("btcusd", 50, 50);
System.out.println("Current Order Book size for BTC / USD: " + (bitfinexDepth.getAsks().length + bitfinexDepth.getBids().length));
System.out.println("First Ask: " + bitfinexDepth.getAsks()[0].toString());
System.out.println("First Bid: " + bitfinexDepth.getBids()[0].toString());
System.out.println(bitfinexDepth.toString());
}
Aggregations