diff --git a/MarketData/MarketDataLib/Helper/MarketDataHelper.cs b/MarketData/MarketDataLib/Helper/MarketDataHelper.cs index 4536f2d..6baff77 100755 --- a/MarketData/MarketDataLib/Helper/MarketDataHelper.cs +++ b/MarketData/MarketDataLib/Helper/MarketDataHelper.cs @@ -5232,9 +5232,16 @@ namespace MarketData.Helper for (int index = 0; index < dates.Count; index++) { DateTime currentDate = dates[index]; - Price price = GetPriceAsOf(symbol, currentDate); - if (null == price) { MDTrace.WriteLine(LogLevel.DEBUG, String.Format("No data for {0} on {1}", symbol, Utility.DateTimeToStringMMHDDHYYYY(currentDate))); continue; } - ; + Price price = GetPriceAsOfV2(symbol, currentDate); + if (null == price) + { + price = GetPriceAsOf(symbol, currentDate); + if (null == price) + { + MDTrace.WriteLine(LogLevel.DEBUG, String.Format("No price for {0} on {1}", symbol, Utility.DateTimeToStringMMHDDHYYYY(currentDate))); + continue; + } + } prices.Add(price); } return prices; @@ -5372,29 +5379,38 @@ namespace MarketData.Helper if (null == tables || 0 == tables.Count) return null; HtmlNodeCollection rows = tables[0].SelectNodes(".//tr"); if (rows.Count < 2) return null; - HtmlNodeCollection data = rows[1].SelectNodes(".//td"); - if (data.Count != 6) - { - MDTrace.WriteLine(LogLevel.DEBUG, String.Format("The price retrieved for {0} does not contain the correct number of data elements (expected 6 data elements).", symbol)); - return null; - } - Price price = new Price(); - price.Source = Price.PriceSource.BigCharts; - price.Symbol = symbol.ToUpper(); - String[] dateElements = data[0].InnerText.Trim().Split(" "); - price.Date = Utility.ParseDate(dateElements[0].Replace("\n",null)); - price.Open = Utility.ParseCurrency(data[1].InnerText.Trim().Replace("\n",null)); - price.High = Utility.ParseCurrency(data[2].InnerText.Trim().Replace("\n",null)); - price.Low = Utility.ParseCurrency(data[3].InnerText.Trim().Replace("\n",null)); - price.Close = price.AdjClose = Utility.ParseCurrency(data[4].InnerText.Trim().Replace("\n",null)); - price.Volume = FeedParser.ParseValueLong(data[5].InnerText.Trim()); - if (!(price.Date.Date.Equals(asOf.Date.Date))) + Prices prices = new Prices(); + for (int rowIndex = 1; rowIndex < rows.Count; rowIndex++) { - MDTrace.WriteLine(LogLevel.DEBUG, String.Format("The price retrieved for {0} does not contain the requested date. Requested date {1} Retrieved date {2}", symbol, price.Date.ToShortDateString(), asOf.ToShortDateString())); + HtmlNodeCollection data = rows[rowIndex].SelectNodes(".//td"); + if (data.Count != 6) + { + MDTrace.WriteLine(LogLevel.DEBUG, String.Format("The price retrieved for {0} does not contain the correct number of data elements (expected 6 data elements).", symbol)); + return null; + } + Price price = new Price(); + price.Source = Price.PriceSource.BigCharts; + price.Symbol = symbol.ToUpper(); + String[] dateElements = data[0].InnerText.Trim().Split(" "); + price.Date = Utility.ParseDate(dateElements[0].Replace("\n", null)); + price.Open = Utility.ParseCurrency(data[1].InnerText.Trim().Replace("\n", null)); + price.High = Utility.ParseCurrency(data[2].InnerText.Trim().Replace("\n", null)); + price.Low = Utility.ParseCurrency(data[3].InnerText.Trim().Replace("\n", null)); + price.Close = price.AdjClose = Utility.ParseCurrency(data[4].InnerText.Trim().Replace("\n", null)); + price.Volume = FeedParser.ParseValueLong(data[5].InnerText.Trim()); + prices.Add(price); + } + + Price selectedPrice = prices.Where(x => x.Date.Date.Equals(asOf.Date.Date)).FirstOrDefault(); + + if (null == selectedPrice) + { + MDTrace.WriteLine(LogLevel.DEBUG, String.Format("No price for {0} on {1}", symbol, asOf.ToShortDateString())); return null; } - return price; + + return selectedPrice; } catch (Exception exception) {