コード例 #1
0
        protected void OnTickersInfoRecv(JObject jObject)
        {
            JArray items = jObject.Value <JArray>("data");

            if (items == null)
            {
                return;
            }
            for (int i = 0; i < items.Count; i++)
            {
                JObject item       = (JObject)items[i];
                string  tickerName = item.Value <string>("symbol");
                Ticker  first      = null;
                for (int index = 0; index < Tickers.Count; index++)
                {
                    Ticker tt = Tickers[index];
                    if (tt.CurrencyPair == tickerName)
                    {
                        first = tt;
                        break;
                    }
                }
                BitmexTicker t = (BitmexTicker)first;
                if (t == null)
                {
                    continue;
                }
                JEnumerable <JToken> props = item.Children();
                foreach (JProperty prop in props)
                {
                    string name  = prop.Name;
                    string value = prop.Value == null ? null : prop.Value.ToString();
                    switch (name)
                    {
                    case "lastPrice":
                        t.Last = FastValueConverter.Convert(value);
                        break;

                    case "highPrice":
                        t.Hr24High = FastValueConverter.Convert(value);
                        break;

                    case "lowPrice":
                        t.Hr24Low = FastValueConverter.Convert(value);
                        break;

                    case "bidPrice":
                        t.HighestBid = FastValueConverter.Convert(value);
                        break;

                    case "askPrice":
                        t.LowestAsk = FastValueConverter.Convert(value);
                        break;

                    case "timestamp":
                        t.Timestamp = t.Time = Convert.ToDateTime(value);
                        break;

                    case "lastChangePcnt":
                        t.Change = FastValueConverter.Convert(value);
                        break;

                    case "volume24h":
                        t.Volume = FastValueConverter.Convert(value);
                        break;
                    }
                }
                t.UpdateTrailings();
                lock (t) {
                    RaiseTickerChanged(t);
                }
            }
        }