本文整理了Java中org.knowm.xchange.dto.marketdata.OrderBook
类的一些代码示例,展示了OrderBook
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OrderBook
类的具体详情如下:
包路径:org.knowm.xchange.dto.marketdata.OrderBook
类名称:OrderBook
[英]DTO representing the exchange order book
[中]代表兑换订单簿的DTO
代码示例来源:origin: knowm/XChange
public static OrderBook convertOrderBook(BinanceOrderbook ob, CurrencyPair pair) {
List<LimitOrder> bids =
ob.bids
.entrySet()
.stream()
.map(e -> new LimitOrder(OrderType.BID, e.getValue(), pair, null, null, e.getKey()))
.collect(Collectors.toList());
List<LimitOrder> asks =
ob.asks
.entrySet()
.stream()
.map(e -> new LimitOrder(OrderType.ASK, e.getValue(), pair, null, null, e.getKey()))
.collect(Collectors.toList());
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: knowm/XChange
/**
* Identical to {@link #equals(Object) equals} method except that this ignores different
* timestamps. In other words, this version of equals returns true if the order internal to the
* OrderBooks are equal but their timestamps are unequal. It returns false if false if any order
* between the two are different.
*
* @param ob
* @return
*/
public boolean ordersEqual(OrderBook ob) {
Date timestamp = new Date();
if (this != null && ob != null) {
OrderBook thisOb = new OrderBook(timestamp, this.getAsks(), this.getBids());
OrderBook thatOb = new OrderBook(timestamp, ob.getAsks(), ob.getBids());
return thisOb.equals(thatOb);
} else {
return this.equals(ob);
}
}
代码示例来源:origin: knowm/XChange
private static void generic(Exchange exchange) throws IOException {
MarketDataService marketDataService = exchange.getMarketDataService();
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.LTC_USD, "LIVE");
System.out.println(orderBook.toString());
System.out.println("size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD, "DEMO");
System.out.println(orderBook.toString());
System.out.println("size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD);
System.out.println(orderBook.toString());
System.out.println("size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
}
代码示例来源:origin: knowm/XChange
private static void generic(Exchange exchange) throws IOException {
// Interested in the public market data feed (no authentication).
MarketDataService marketDataService = exchange.getMarketDataService();
// Get the order book data for BTC/CNY.
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_CNY);
System.out.println(orderBook);
System.out.println("asks: " + orderBook.getAsks());
System.out.println("bids: " + orderBook.getBids());
System.out.println("size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
}
代码示例来源:origin: knowm/XChange
public static void main(String[] args) throws IOException {
// Use the factory to get Cex.IO exchange API using default settings
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(AbucoinsExchange.class.getName());
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = exchange.getMarketDataService();
// Get the latest order book data for GHs/BTC
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD);
System.out.println(
"Current Order Book size for BTC/USD: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println("Timestamp: " + orderBook.getTimeStamp().toString());
// System.out.println(orderBook.toString());
}
}
代码示例来源:origin: knowm/XChange
List<LimitOrder> asks = orderBook.getAsks();
LimitOrder lowestAsk = orderBook.getAsks().get(0);
price = lowestAsk.getLimitPrice();
} else {
代码示例来源:origin: knowm/XChange
private static void generic(Exchange lakebtcExchange) throws IOException {
MarketDataService marketDataService = lakebtcExchange.getMarketDataService();
// Get the latest full order book data for NMC/XRP
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD);
System.out.println(orderBook.toString());
System.out.println(
"full orderbook size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
// Get the latest partial size order book data for NMC/XRP
orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_CNY);
System.out.println(orderBook.toString());
System.out.println(
"full orderbook size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
}
代码示例来源:origin: knowm/XChange
public static void generic(MarketDataService marketDataService) throws IOException {
/* get OrderBook data */
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.ETH_EUR);
// System.out.println(orderBook.toString());
System.out.println(
"Current Order Book size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println(
"Last Ask: " + orderBook.getAsks().get(orderBook.getAsks().size() - 1).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(
"Last Bid: " + orderBook.getBids().get(orderBook.getBids().size() - 1).toString());
}
代码示例来源:origin: knowm/XChange
public static void main(String[] args) throws IOException {
// Use the factory to get Cex.IO exchange API using default settings
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CexIOExchange.class.getName());
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = exchange.getMarketDataService();
// Get the latest order book data for GHs/BTC
OrderBook orderBook =
marketDataService.getOrderBook(new CurrencyPair(Currency.GHs, Currency.BTC));
System.out.println(
"Current Order Book size for GHS/BTC: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println("Timestamp: " + orderBook.getTimeStamp().toString());
// System.out.println(orderBook.toString());
}
}
代码示例来源:origin: knowm/XChange
public static OrderBook adaptOrders(CoinEggOrders coinEggOrders, CurrencyPair currencyPair) {
List<LimitOrder> asks =
Stream.of(coinEggOrders.getAsks())
.map(order -> adaptOrder(order, OrderType.ASK, currencyPair))
.collect(Collectors.toList());
List<LimitOrder> bids =
Stream.of(coinEggOrders.getBids())
.map(order -> adaptOrder(order, OrderType.BID, currencyPair))
.collect(Collectors.toList());
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: knowm/XChange
private static void generic(MarketDataService marketDataService) throws IOException {
// Get the latest order book data for CurrencyPair.BTC_USD
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD, 10000, 10000);
System.out.println(
"Current Order Book size for BTC / USD: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(orderBook.toString());
}
代码示例来源:origin: knowm/XChange
private static void generic(MarketDataService marketDataService) throws IOException {
// Get the latest order book data for ETH/BTC
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.ETH_BTC);
System.out.println(
"Current Order Book size for BTC / USD: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println(
"Last Ask: " + orderBook.getAsks().get(orderBook.getAsks().size() - 1).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(
"Last Bid: " + orderBook.getBids().get(orderBook.getBids().size() - 1).toString());
}
代码示例来源:origin: knowm/XChange
public static OrderBook adaptOrderBook(
CurrencyPair currencyPair, CoindirectOrderbook coindirectOrderbook) {
List<LimitOrder> bids =
coindirectOrderbook
.bids
.stream()
.map(
e -> new LimitOrder(Order.OrderType.BID, e.size, currencyPair, null, null, e.price))
.collect(Collectors.toList());
List<LimitOrder> asks =
coindirectOrderbook
.asks
.stream()
.map(
e -> new LimitOrder(Order.OrderType.ASK, e.size, currencyPair, null, null, e.price))
.collect(Collectors.toList());
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: knowm/XChange
private static void generic(Exchange quoineExchange) throws IOException {
// Interested in the public market data feed (no authentication)
MarketDataService quoineMarketDataService = quoineExchange.getMarketDataService();
// Get the latest full order book data for NMC/XRP
OrderBook orderBook = quoineMarketDataService.getOrderBook(CurrencyPair.BTC_USD);
System.out.println(orderBook.toString());
System.out.println(
"full orderbook size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
}
代码示例来源:origin: knowm/XChange
private static void generic(MarketDataService marketDataService) throws IOException {
// Get the latest order book data for BTC/USD
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD);
System.out.println(
"Current Order Book size for BTC / USD: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println(
"Last Ask: " + orderBook.getAsks().get(orderBook.getAsks().size() - 1).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(
"Last Bid: " + orderBook.getBids().get(orderBook.getBids().size() - 1).toString());
// System.out.println(orderBook.toString());
}
代码示例来源:origin: knowm/XChange
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
KunaAskBid kunaAskBid = getKunaOrderBook(currencyPair);
List<LimitOrder> asks =
Arrays.stream(kunaAskBid.getAsks())
.map(kunaOrder -> mapKunaOrder2LimitOrder(kunaOrder, currencyPair))
.collect(Collectors.toList());
List<LimitOrder> bids =
Arrays.stream(kunaAskBid.getBids())
.map(kunaOrder -> mapKunaOrder2LimitOrder(kunaOrder, currencyPair))
.collect(Collectors.toList());
return new OrderBook(new Date(), asks, bids);
}
代码示例来源:origin: knowm/XChange
private static void generic(Exchange okcoinExchange) throws IOException {
// Interested in the public market data feed (no authentication)
MarketDataService marketDataService = okcoinExchange.getMarketDataService();
// Get the latest full order book data for NMC/XRP
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_CNY);
System.out.println(orderBook.toString());
System.out.println(
"full orderbook size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
}
代码示例来源:origin: knowm/XChange
private static void generic(MarketDataService marketDataService) throws IOException {
// Get the latest order book data for BTC/USD
OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_EUR);
System.out.println(
"Current Order Book size for BTC / USD: "
+ (orderBook.getAsks().size() + orderBook.getBids().size()));
System.out.println("First Ask: " + orderBook.getAsks().get(0).toString());
System.out.println(
"Last Ask: " + orderBook.getAsks().get(orderBook.getAsks().size() - 1).toString());
System.out.println("First Bid: " + orderBook.getBids().get(0).toString());
System.out.println(
"Last Bid: " + orderBook.getBids().get(orderBook.getBids().size() - 1).toString());
// System.out.println(orderBook.toString());
}
代码示例来源:origin: knowm/XChange
public static OrderBook adaptOrderBook(BiboxOrderBook orderBook, CurrencyPair currencyPair) {
return new OrderBook(
new Date(orderBook.getUpdateTime()),
orderBook
.getAsks()
.stream()
.map(e -> adaptOrderBookOrder(e, OrderType.ASK, currencyPair))
.collect(Collectors.toList()),
orderBook
.getBids()
.stream()
.map(e -> adaptOrderBookOrder(e, OrderType.BID, currencyPair))
.collect(Collectors.toList()));
}
代码示例来源:origin: knowm/XChange
private static void generic(final Exchange liquiExchange) throws IOException {
final MarketDataService marketDataService = liquiExchange.getMarketDataService();
final OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.LTC_BTC);
System.out.println(orderBook.toString());
System.out.println(
"full orderbook size: " + (orderBook.getAsks().size() + orderBook.getBids().size()));
}
内容来源于网络,如有侵权,请联系作者删除!