private OrderBook BuildOrderBook(ProExchange.JSON.API.Notifications.OrderBook response)
 {
     var orderbook = new OrderBook { Version = response.Version };
     foreach (var data in response.List)
     {
         orderbook.Sides[(int)data.Side.SimplifyOrderSide()].Add(data.Price, new OrderBookDetail(data.Price) { Quantity = data.Size });
     }
     return orderbook;
 }
        public void Update(ProExchange.JSON.API.Notifications.OrderBook response)
        {
            lock (this)
            {
                OrderBook orderbook;
                var isNew = orderbooks.TryGetValue(response.Symbol, out orderbook);

                switch (response.Type)
                {
                    case OrderBookType.FULL:
                        orderbook = new OrderBook();
                        orderbooks[response.Symbol] = orderbook;
                        break;
                    case OrderBookType.INCREMENTAL:
                        var next = NextVersion(orderbook);
                        if (next != response.Version)
                            RequestFullOrderBook(response.Symbol);
                        break;
                    default:
                        return;
                }

                foreach (var data in response.List)
                {
                    var side = orderbook.Sides[(int)data.Side.SimplifyOrderSide()];
                    OrderBookDetail detail;
                    if (!side.TryGetValue(data.Price, out detail))
                    {
                        detail = new OrderBookDetail(data.Price);
                        side.Add(detail.Price, detail);
                    }
                    detail.Quantity += data.Size;
                    if (detail.Quantity == 0) side.Remove(detail.Price);
                }
                orderbook.Version = response.Version;
            }
        }