diff --git a/TDAmeritrade/Utilities/TDStreamJsonProcessor.cs b/TDAmeritrade/Utilities/TDStreamJsonProcessor.cs index 1153019..ae8c250 100644 --- a/TDAmeritrade/Utilities/TDStreamJsonProcessor.cs +++ b/TDAmeritrade/Utilities/TDStreamJsonProcessor.cs @@ -29,32 +29,36 @@ public void Parse(string json) } else if (job.ContainsKey("data")) { - var service = job["data"].First.First.First.Value(); - var content = job["data"].First.Last.First.First as JObject; - var tmstamp = job["data"].First["timestamp"].Value(); + var data = job["data"] as JArray; + foreach (var item in data) + { + var service = item.First.First.Value(); + var content = item.Last.First.First as JObject; + var tmstamp = item["timestamp"].Value(); - if (content == null) - return; + if (content == null) + return; - if (service == "QUOTE") - { - ParseQuote(tmstamp, content); - } - else if (service == "CHART_FUTURES") - { - ParseChartFutures(tmstamp, content); - } - else if (service == "CHART_EQUITY") - { - ParseChartEquity(tmstamp, content); - } - else if (service == "LISTED_BOOK" || service == "NASDAQ_BOOK" || service == "OPTIONS_BOOK") - { - ParseBook(tmstamp, content, service); - } - else if (service == "TIMESALE_EQUITY" || service == "TIMESALE_FUTURES" || service == "TIMESALE_FOREX" || service == "TIMESALE_OPTIONS") - { - ParseTimeSaleEquity(tmstamp, content); + if (service == "QUOTE") + { + ParseQuote(tmstamp, content); + } + else if (service == "CHART_FUTURES") + { + ParseChartFutures(tmstamp, content); + } + else if (service == "CHART_EQUITY") + { + ParseChartEquity(tmstamp, content); + } + else if (service == "LISTED_BOOK" || service == "NASDAQ_BOOK" || service == "OPTIONS_BOOK") + { + ParseBook(tmstamp, content, service); + } + else if (service == "TIMESALE_EQUITY" || service == "TIMESALE_FUTURES" || service == "TIMESALE_FOREX" || service == "TIMESALE_OPTIONS") + { + ParseTimeSaleEquity(tmstamp, content); + } } } }