org.knowm.xchange.dto.marketdata.OrderBook.getOrders()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.knowm.xchange.dto.marketdata.OrderBook.getOrders()方法的一些代码示例,展示了OrderBook.getOrders()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OrderBook.getOrders()方法的具体详情如下:
包路径:org.knowm.xchange.dto.marketdata.OrderBook
类名称:OrderBook
方法名:getOrders

OrderBook.getOrders介绍

暂无

代码示例

代码示例来源:origin: knowm/XChange

/**
 * Given a new LimitOrder, it will replace a matching limit order in the orderbook if one is
 * found, or add the new LimitOrder if one is not. timeStamp will be updated if the new timestamp
 * is non-null and in the future.
 *
 * @param limitOrder the new LimitOrder
 */
public void update(LimitOrder limitOrder) {
 update(getOrders(limitOrder.getType()), limitOrder);
 updateDate(limitOrder.getTimestamp());
}

代码示例来源:origin: knowm/XChange

/**
 * Given an OrderBookUpdate, it will replace a matching limit order in the orderbook if one is
 * found, or add a new if one is not. timeStamp will be updated if the new timestamp is non-null
 * and in the future.
 *
 * @param orderBookUpdate the new OrderBookUpdate
 */
public void update(OrderBookUpdate orderBookUpdate) {
 LimitOrder limitOrder = orderBookUpdate.getLimitOrder();
 List<LimitOrder> limitOrders = getOrders(limitOrder.getType());
 int idx = Collections.binarySearch(limitOrders, limitOrder);
 if (idx >= 0) {
  limitOrders.remove(idx);
 } else {
  idx = -idx - 1;
 }
 if (orderBookUpdate.getTotalVolume().compareTo(BigDecimal.ZERO) != 0) {
  LimitOrder updatedOrder = withAmount(limitOrder, orderBookUpdate.getTotalVolume());
  limitOrders.add(idx, updatedOrder);
 }
 updateDate(limitOrder.getTimestamp());
}

代码示例来源:origin: bitrich-info/xchange-stream

public static String hasErrors(OrderBook book) {
  List<LimitOrder> asks = book.getOrders(Order.OrderType.ASK);
  if (!Objects.equals(asks, book.getAsks())) return "Asks did not match for OrderBook";
  List<LimitOrder> bids = book.getOrders(Order.OrderType.BID);
  if (!Objects.equals(bids, book.getBids())) return "Bids did not match for OrderBook";
  LimitOrder bestAsk = null;
  if (!asks.isEmpty()) {
    bestAsk = asks.get(0);
    String askCheck = hasErrors(asks.iterator());
    if (askCheck != null) return askCheck;
  }
  LimitOrder bestBid = null;
  if (!bids.isEmpty()) {
    bestBid = bids.get(0);
    String bidCheck = hasErrors(CollectionUtils.descendingIterable(bids).iterator());
    if (bidCheck != null) return bidCheck;
  }
  if (bestAsk != null && bestBid != null
      && bestAsk.getLimitPrice().compareTo(bestBid.getLimitPrice()) <= 0)
    return format("Got incorrect best ask and bid %s, %s", bestAsk, bestBid);
  return null;
}

代码示例来源:origin: org.knowm.xchange/xchange-core

/**
 * Given a new LimitOrder, it will replace a matching limit order in the orderbook if one is
 * found, or add the new LimitOrder if one is not. timeStamp will be updated if the new timestamp
 * is non-null and in the future.
 *
 * @param limitOrder the new LimitOrder
 */
public void update(LimitOrder limitOrder) {
 update(getOrders(limitOrder.getType()), limitOrder);
 updateDate(limitOrder.getTimestamp());
}

代码示例来源:origin: org.knowm.xchange/xchange-core

/**
 * Given an OrderBookUpdate, it will replace a matching limit order in the orderbook if one is
 * found, or add a new if one is not. timeStamp will be updated if the new timestamp is non-null
 * and in the future.
 *
 * @param orderBookUpdate the new OrderBookUpdate
 */
public void update(OrderBookUpdate orderBookUpdate) {
 LimitOrder limitOrder = orderBookUpdate.getLimitOrder();
 List<LimitOrder> limitOrders = getOrders(limitOrder.getType());
 int idx = Collections.binarySearch(limitOrders, limitOrder);
 if (idx >= 0) {
  limitOrders.remove(idx);
 } else {
  idx = -idx - 1;
 }
 if (orderBookUpdate.getTotalVolume().compareTo(BigDecimal.ZERO) != 0) {
  LimitOrder updatedOrder = withAmount(limitOrder, orderBookUpdate.getTotalVolume());
  limitOrders.add(idx, updatedOrder);
 }
 updateDate(limitOrder.getTimestamp());
}

相关文章