private async void HandleStockDataRequest(StockDataRequestMessage message)
 {
     if (message.Tickers != null || message.Positions != null) //Request for multiple securities
     {
         await GetSecurityInfo(message);
     }
     if (!string.IsNullOrEmpty(message.Ticker)) //ticker property is not null, request for one security
     {
         var isScreener = message.IsScreenerRequest;
         var isPreview  = message.IsTradePreviewRequest;
         await GetSecurityInfo(message.Ticker, isScreener, isPreview);
     }
 }
        /// <summary>
        /// Method takes a request for multiple tickers or multiple positions
        /// and sends a listed of updated data
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task GetSecurityInfo(StockDataRequestMessage message)
        {
            var tickersToQuery = new List <string>();

            var positionsQuery = false;
            var tickersQuery   = false;

            if (message.Tickers != null && message.Tickers.Count > 0)
            {
                tickersToQuery = message.Tickers;
                tickersQuery   = true;
            }
            else if (message.Positions != null && message.Positions.Count > 0)
            {
                tickersToQuery = message.Positions.Select(s => s.Ticker).Distinct().ToList();
                positionsQuery = true;
            }

            using (var yahooAPI = new YahooAPIService())
            {
                var resultList = await yahooAPI.GetMultipleSecurities(tickersToQuery);

                //Return response. Message's boolean is True if this is a startup call of this method.
                if (message.IsStartupRequest && positionsQuery)
                {
                    Messenger.Default.Send <PositionPricingMessage>(new PositionPricingMessage(resultList, true));
                }
                else if (message.IsStartupRequest && tickersQuery)
                {
                    Messenger.Default.Send <StockDataResponseMessage>(new StockDataResponseMessage(resultList, true));
                }
                else
                {
                    Messenger.Default.Send <StockDataResponseMessage>(new StockDataResponseMessage(resultList, false));
                }
            }
        }