Example #1
0
        static void ParseQuotes(string data)
        {
            var quotes = data.Split(new[] { ";", "/r/n" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var quote in quotes)
            {
                var items = quote.Split(new[] { '=' });
                if (items.Length != 2)
                {
                    continue;
                }
                var symbol = items[0];
                var price  = decimal.Parse(items[1]);

                var prevQuote = currentMarketState.ContainsKey(items[0]) ? currentMarketState[items[0]] : null;

                if (prevQuote == null)
                {
                    currentMarketState[items[0]] = new QuoteView
                    {
                        Price = price,
                        Trend = Trend.None
                    }
                }
                ;
                else
                {
                    currentMarketState[items[0]].Trend = currentMarketState[items[0]].Price < price ? Trend.Increase : Trend.Decrease;
                    currentMarketState[items[0]].Price = price;
                }
            }
        }
Example #2
0
        static void ParseQuotes(string data)
        {
            var quotes = data.Split(new[] { ";", "/r/n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var quote in quotes)
            {
                var items = quote.Split(new[] { '=' });
                if (items.Length != 2)
                    continue;
                var symbol = items[0];
                var price = decimal.Parse(items[1]);

                var prevQuote = currentMarketState.ContainsKey(items[0]) ? currentMarketState[items[0]] : null;

                if (prevQuote == null)
                    currentMarketState[items[0]] = new QuoteView
                    {
                        Price = price,
                        Trend = Trend.None
                    };
                else
                {
                    currentMarketState[items[0]].Trend = currentMarketState[items[0]].Price < price ? Trend.Increase : Trend.Decrease;
                    currentMarketState[items[0]].Price = price;
                }
            }
        }