Ejemplo n.º 1
0
        public void FilterList()
        {
            try
            {
                FilteredInputList = new List <List <DailyHistoricalPriceData> >();
                var minDate = InputList.Min(e => e.MarketDate);
                var maxDate = InputList.Max(e => e.MarketDate);

                var Filter    = new List <DailyHistoricalPriceData>();
                var startDate = minDate;
                while (startDate <= maxDate)
                {
                    if (!(startDate.DayOfWeek == DayOfWeek.Sunday || startDate.DayOfWeek == DayOfWeek.Saturday))
                    {
                        var test = InputList.Exists(e => e.MarketDate.Date == startDate.Date);
                        if (InputList.Exists(e => e.MarketDate.Date == startDate.Date))
                        {
                            Filter.Add(InputList.Find(e => e.MarketDate.Date == startDate.Date));
                        }
                        else if (Filter.Count == 1)
                        {
                            FilteredInputList[FilteredInputList.Count - 1].Add(Filter[0]);
                            Filter = new List <DailyHistoricalPriceData>();
                        }
                        else if (Filter.Count > 1)
                        {
                            FilteredInputList.Add(Filter);
                            Filter = new List <DailyHistoricalPriceData>();
                        }
                    }
                    startDate = startDate.AddDays(1);
                }
                if (Filter.Count == 1)
                {
                    FilteredInputList[FilteredInputList.Count - 1].Add(Filter[0]);
                    Filter = new List <DailyHistoricalPriceData>();
                }
                else if (Filter.Count > 1)
                {
                    FilteredInputList.Add(Filter);
                    Filter = new List <DailyHistoricalPriceData>();
                }
            }
            catch (Exception exc)
            {
            }
        }