/** * 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()); }
); final OrderBookUpdate bidUpdate = new OrderBookUpdate( bid.getType(), bid.getTradableAmount(), bid.getTradableAmount().subtract(tradeAmount) ); final OrderBookUpdate askUpdate = new OrderBookUpdate( ask.getType(), ask.getTradableAmount(),
ob.bids.forEach((key, value) -> subscription.orderBook.update(new OrderBookUpdate( OrderType.BID, null, depth.getEventTime(), value))); ob.asks.forEach((key, value) -> subscription.orderBook.update(new OrderBookUpdate( OrderType.ASK, null,
break; case MDUpdateAction.DELETE: OrderBookUpdate orderBookUpdate = new OrderBookUpdate( limitOrder.getType(), limitOrder.getTradableAmount(),
/** * 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()); }