/// <summary> /// Agrregate a data row to hourly,daily data... /// </summary> /// <param name="priceRow"> source data arregated to [toSumTbl] </param> /// <param name="changeVolume"> volume qty changed and is cumulated to total volume </param> /// <param name="timeScale"> aggregate to hour,day,week... data </param> /// <param name="cultureInfo"> culture info that need to caculate the start of the week param> /// <param name="toSumTbl"> destination table</param> public static void AggregatePriceData(databases.baseDS.priceDataRow priceRow, decimal changeVolume, AppTypes.TimeScale timeScale, CultureInfo cultureInfo, databases.baseDS.priceDataSumDataTable toSumTbl) { DateTime dataDate = AggregateDateTime(timeScale, priceRow.onDate, cultureInfo); databases.baseDS.priceDataSumRow priceDataSumRow; priceDataSumRow = AppLibs.FindAndCache(toSumTbl, priceRow.stockCode, timeScale.Code, dataDate); if (priceDataSumRow == null) { priceDataSumRow = toSumTbl.NewpriceDataSumRow(); databases.AppLibs.InitData(priceDataSumRow); priceDataSumRow.type = timeScale.Code; priceDataSumRow.stockCode = priceRow.stockCode; priceDataSumRow.onDate = dataDate; priceDataSumRow.openPrice = priceRow.openPrice; priceDataSumRow.closePrice = priceRow.closePrice; object lastPriceObj = lastClosePrices.Find(timeScale.Code + priceRow.stockCode); if (lastPriceObj!=null) { priceDataSumRow.openPrice = (decimal)lastPriceObj; } else priceDataSumRow.openPrice = priceDataSumRow.closePrice; toSumTbl.AddpriceDataSumRow(priceDataSumRow); } priceDataSumRow.closePrice = priceRow.closePrice; lastClosePrices.Add(timeScale.Code + priceRow.stockCode, priceRow.closePrice); if (priceDataSumRow.highPrice < priceRow.highPrice) priceDataSumRow.highPrice = priceRow.highPrice; if (priceDataSumRow.lowPrice > priceRow.lowPrice) priceDataSumRow.lowPrice = priceRow.lowPrice; priceDataSumRow.volume += changeVolume; }