public void ApplySnapshot(JObject jObject, Ticker ticker) { ticker.OrderBook.BeginUpdate(); try { ticker.OrderBook.Clear(); OrderBook orderBook = ticker.OrderBook; JArray jbids = jObject.Value <JArray>("Z"); JArray jasks = jObject.Value <JArray>("S"); List <OrderBookEntry> entries = orderBook.Asks; List <OrderBookEntry> entriesInverted = orderBook.AsksInverted; for (int i = 0; i < jasks.Count; i++) { JObject item = (JObject)jasks[i]; entries.Add(new OrderBookEntry() { ValueString = item.Value <string>("R"), AmountString = item.Value <string>("Q") }); if (entriesInverted != null) { entriesInverted.Insert(0, new OrderBookEntry() { ValueString = item.Value <string>("R"), AmountString = item.Value <string>("Q") }); } } entries = orderBook.Bids; for (int i = 0; i < jbids.Count; i++) { JObject item = (JObject)jbids[i]; entries.Add(new OrderBookEntry() { ValueString = item.Value <string>("R"), AmountString = item.Value <string>("Q") }); } } finally { ticker.OrderBook.IsDirty = false; ticker.OrderBook.EndUpdate(); } ticker.ClearTradeHistory(); JArray jtrades = jObject.Value <JArray>("f"); foreach (JObject item in jtrades) { TradeInfoItem t = new TradeInfoItem(null, ticker); t.AmountString = item.Value <string>("Q"); t.RateString = item.Value <string>("P"); t.Time = new DateTime(Convert.ToInt64(item.Value <string>("T"))).ToLocalTime(); t.TimeString = t.Time.ToLongTimeString(); t.Type = (item.Value <string>("OT")) == "BUY" ? TradeType.Buy : TradeType.Sell; ticker.AddTradeHistoryItem(t); } if (ticker.HasTradeHistorySubscribers) { ticker.RaiseTradeHistoryChanged(new TradeHistoryChangedEventArgs() { NewItems = ticker.TradeHistory }); } }