MarketData GetNewMarketData(DateTime startDate, DateTime endDate, MarketData md) { MarketData newMD = new MarketData(startDate, endDate, md.Ticker); DateTime curDate = startDate; while (curDate <= endDate) { if (md.IsExistDate(curDate)) { DOHLC dohlc = md.GetData(curDate); newMD.AddDatum(dohlc); } curDate = curDate.AddDays(1); } return newMD; }
double GetUpDownRate(MarketData md, DateTime prevDate, DateTime curDate) { double curPrice = md.GetData(curDate).OHLC.Close; double prevPrice = md.GetData(prevDate).OHLC.Close; return (curPrice / prevPrice) - 1; }
void UpdatePrevDataGridView_Raw(MarketData md) { DateTime curDate = md.StartDate; String ticker = md.Ticker; String desc = TickerNameMap.Ins().GetDesc(ticker); while (curDate <= md.EndDate) { if (md.IsExistDate(curDate)) { DOHLC datum = md.GetData(curDate); double value = datum.OHLC.Close; int index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = curDate.ToString("yyyy-MM-dd"); dataGridView1.Rows[index].Cells[1].Value = ticker; dataGridView1.Rows[index].Cells[2].Value = desc; dataGridView1.Rows[index].Cells[3].Value = value; } curDate = curDate.AddDays(1); } }