namespace OpenLimits { using System.Collections.Generic; public class Orderbook { private readonly Dictionary _bids = new Dictionary(); private readonly Dictionary _asks = new Dictionary(); public void Update(OrderbookResponse changes) { foreach(var ask in changes.asks) { if (ask.qty == 0){ if (_asks.ContainsKey(ask.price)) { _asks.Remove(ask.price); } } else { _asks.Add(ask.price, ask.qty); } } foreach(var bid in changes.bids) { if (bid.qty == 0){ if (_bids.ContainsKey(bid.price)) { _bids.Remove(bid.price); } } else { _bids.Add(bid.price, bid.qty); } } } } }