internal void CreateMonthly(Construct wts_, Technicals.ProductBase[] products_) { List<DateTime> dates = new List<DateTime>(); List<double> vals = new List<double>(); int countOfZerosThisMonth = 0; int numberOfRebalsThisMomth = 0; int currentMonth = 0; int currentYear = 0; for (int i = 0; i < wts_.Dates.Count; ++i) { if (wts_.Dates[i].Year != currentYear || wts_.Dates[i].Month != currentMonth) { if (currentMonth != 0) { dates.Add(new DateTime(currentYear, currentMonth, 1)); vals.Add(Convert.ToDouble(countOfZerosThisMonth) / Convert.ToDouble(numberOfRebalsThisMomth)); } countOfZerosThisMonth = 0; numberOfRebalsThisMomth = 0; } double[] weightsThisRebal = wts_.GetValues(wts_.Dates[i]); for(int y=0;y<weightsThisRebal.Length;++y) if (weightsThisRebal[y] == 0.0 && products_[y].IsValid(wts_.Dates[i])) ++countOfZerosThisMonth; ++numberOfRebalsThisMomth; currentMonth = wts_.Dates[i].Month; currentYear = wts_.Dates[i].Year; } dates.Add(new DateTime(currentYear, currentMonth, 1)); vals.Add(Convert.ToDouble(countOfZerosThisMonth) / Convert.ToDouble(numberOfRebalsThisMomth)); foreach (DateTime date in dates) dt.Columns.Add(date.ToString("MMM yy"), typeof(double)); DataRow row = dt.NewRow(); for (int i = 0; i < vals.Count; ++i) row[i] = vals[i]; dt.Rows.Add(row); Chart.DataSource = dt; }