From d0625cf55e105bfc4b80cf749492c3c51e31d1a6 Mon Sep 17 00:00:00 2001 From: nventimiglia Date: Mon, 10 May 2021 21:49:35 -0700 Subject: [PATCH] fix for mutli-data stream singals --- .../Utilities/TDStreamJsonProcessor.cs | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) 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); + } } } }