コード例 #1
0
        // Set [dataIsDailyPrice] = true if [priceTbl] contains all day data (not a real time data.

        /// <summary>
        /// Agrregate a data table to hourly,daily data...
        /// </summary>
        /// <param name="priceTbl">source data to be aggregated </param>
        /// <param name="cultureCode"></param>
        /// <param name="isDailyPrice">
        ///  Volume can be accumulated real-time or at the end of the day.
        ///  - If data is collected in realtime,
        ///  updateVolume table is used to culmulated the volume for each day and that will need some more resources.
        ///  - If data is collected at the end of the day, the voulume alredy is the total volume and updateVolume table
        ///  should not be used to save resources.
        /// </param>
        /// <param name="onAggregateDataFunc">function that was triggered after each agrregation</param>
        public static void AggregatePriceData(data.baseDS.priceDataDataTable priceTbl, CultureInfo cultureInfo,
                                              OnAggregateData onAggregateDataFunc)
        {
            data.baseDS.priceDataSumDataTable priceSumDataTbl = new data.baseDS.priceDataSumDataTable();
            agrregateStat myAgrregateStat = new agrregateStat();

            myAgrregateStat.maxCount  = priceTbl.Count;
            priceTbl.DefaultView.Sort = priceTbl.onDateColumn.ColumnName + "," + priceTbl.stockCodeColumn.ColumnName;
            data.baseDS.priceDataRow priceDataRow;

            decimal changeVolume;
            int     lastYear = int.MinValue;

            for (int idx = 0; idx < priceTbl.DefaultView.Count; idx++)
            {
                priceDataRow          = (data.baseDS.priceDataRow)priceTbl.DefaultView[idx].Row;
                myAgrregateStat.count = idx;
                if (onAggregateDataFunc != null)
                {
                    onAggregateDataFunc(myAgrregateStat);
                }
                if (myAgrregateStat.cancel)
                {
                    priceSumDataTbl.Clear();
                    break;
                }
                changeVolume = priceDataRow.volume;
                foreach (AppTypes.TimeScale timeScale in AppTypes.myTimeScales)
                {
                    if (timeScale.Type == AppTypes.TimeScaleTypes.RealTime)
                    {
                        continue;
                    }
                    AggregatePriceData(priceDataRow, changeVolume, timeScale, cultureInfo, priceSumDataTbl);
                    Application.DoEvents();
                }
                //Update and clear cache to speed up the performance
                if (lastYear != priceDataRow.onDate.Year)
                {
                    application.DbAccess.UpdateData(priceSumDataTbl);
                    priceSumDataTbl.Clear();
                    lastYear = priceDataRow.onDate.Year;
                }
            }
            application.DbAccess.UpdateData(priceSumDataTbl);
        }
コード例 #2
0
ファイル: AppLibs.cs プロジェクト: oghenez/trade-software
        /// <summary>
        /// Agrregate a data table to hourly,daily data...
        /// </summary>
        /// <param name="priceTbl">source data to be aggregated </param>
        /// <param name="cultureCode"></param>
        /// <param name="isDailyPrice">
        ///  Volume can be accumulated real-time or at the end of the day.
        ///  - If data is collected in realtime,
        ///  updateVolume table is used to culmulated the volume for each day and that will need some more resources.
        ///  - If data is collected at the end of the day, the voulume alredy is the total volume and updateVolume table
        ///  should not be used to save resources.
        /// </param>
        /// <param name="onAggregateDataFunc">function that was triggered after each agrregation</param>
        public static void AggregatePriceData(databases.baseDS.priceDataDataTable priceTbl, CultureInfo cultureInfo,
                                              OnAggregateData onAggregateDataFunc)
        {
            databases.baseDS.priceDataSumDataTable priceSumDataTbl = new databases.baseDS.priceDataSumDataTable();
            AgrregateInfo myAgrregateStat = new AgrregateInfo();

            myAgrregateStat.maxCount = priceTbl.Count;

            decimal changeVolume;
            int     lastYear = int.MinValue;

            for (int idx = 0; idx < priceTbl.Count; idx++)
            {
                myAgrregateStat.count = idx;
                if (onAggregateDataFunc != null)
                {
                    onAggregateDataFunc(myAgrregateStat);
                }
                if (myAgrregateStat.cancel)
                {
                    priceSumDataTbl.Clear();
                    break;
                }
                Application.DoEvents();

                changeVolume = priceTbl[idx].volume;
                foreach (AppTypes.TimeScale timeScale in AppTypes.myTimeScales)
                {
                    if (timeScale.Type == AppTypes.TimeScaleTypes.RealTime)
                    {
                        continue;
                    }
                    AggregatePriceData(priceTbl[idx], changeVolume, timeScale, cultureInfo, priceSumDataTbl);
                }
                //Update and clear cache to speed up the performance
                if (lastYear != priceTbl[idx].onDate.Year)
                {
                    databases.DbAccess.UpdateData(priceSumDataTbl);
                    priceSumDataTbl.Clear();
                    lastYear = priceTbl[idx].onDate.Year;
                }
                //databases.DbAccess.UpdateData(priceDataRow);
            }
            databases.DbAccess.UpdateData(priceSumDataTbl);
            priceSumDataTbl.Dispose();
        }
コード例 #3
0
ファイル: AppLibs.cs プロジェクト: oghenez/trade-software
        /// <summary>
        /// Agrregate a data table to hourly,daily data...
        /// </summary>
        /// <param name="priceTbl">source data to be aggregated </param>
        /// <param name="cultureCode"></param>
        /// <param name="isDailyPrice">
        ///  Volume can be accumulated real-time or at the end of the day. 
        ///  - If data is collected in realtime, 
        ///  updateVolume table is used to culmulated the volume for each day and that will need some more resources.
        ///  - If data is collected at the end of the day, the voulume alredy is the total volume and updateVolume table 
        ///  should not be used to save resources.
        /// </param>
        /// <param name="onAggregateDataFunc">function that was triggered after each agrregation</param>
        public static void AggregatePriceData(databases.baseDS.priceDataDataTable priceTbl, CultureInfo cultureInfo,
                                                  OnAggregateData onAggregateDataFunc)
            {
                databases.baseDS.priceDataSumDataTable priceSumDataTbl = new databases.baseDS.priceDataSumDataTable();
                AgrregateInfo myAgrregateStat = new AgrregateInfo();
                myAgrregateStat.maxCount = priceTbl.Count;

                decimal changeVolume;
                int lastYear = int.MinValue;
                for (int idx = 0; idx < priceTbl.Count; idx++)
                {
                    myAgrregateStat.count = idx;
                    if (onAggregateDataFunc != null) onAggregateDataFunc(myAgrregateStat);
                    if (myAgrregateStat.cancel)
                    {
                        priceSumDataTbl.Clear();
                        break;
                    }
                    Application.DoEvents();

                    changeVolume = priceTbl[idx].volume;
                    foreach (AppTypes.TimeScale timeScale in AppTypes.myTimeScales)
                    {
                        if (timeScale.Type == AppTypes.TimeScaleTypes.RealTime) continue;
                        AggregatePriceData(priceTbl[idx], changeVolume, timeScale, cultureInfo, priceSumDataTbl);
                    }
                    //Update and clear cache to speed up the performance
                    if (lastYear != priceTbl[idx].onDate.Year)
                    {
                        databases.DbAccess.UpdateData(priceSumDataTbl);
                        priceSumDataTbl.Clear();
                        lastYear = priceTbl[idx].onDate.Year;
                    }
                    //databases.DbAccess.UpdateData(priceDataRow);
                }
                databases.DbAccess.UpdateData(priceSumDataTbl);
                priceSumDataTbl.Dispose();
            }
コード例 #4
0
ファイル: AppLibs.cs プロジェクト: oghenez/trade-software
 public static void ReAggregatePriceData(string code, CultureInfo stockCulture, OnAggregateData onAggregateDataFunc)
 {
     //Load main  pricedata
     baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
     DbAccess.LoadData(priceTbl, AppTypes.MainDataTimeScale.Code, DateTime.MinValue, DateTime.MaxValue, code);
     if (priceTbl == null) return;
     //Delete all summ pricedata
     DbAccess.DeletePriceSumData(code);
     ClearLastClosePrices();
     AggregatePriceData(priceTbl, stockCulture, onAggregateDataFunc);
     priceTbl.Dispose();
 }
コード例 #5
0
ファイル: lib.cs プロジェクト: oghenez/trade-software
        // Set [dataIsDailyPrice] = true if [priceTbl] contains all day data (not a real time data.

        /// <summary>
        /// Agrregate a data table to hourly,daily data...
        /// </summary>
        /// <param name="priceTbl">source data to be aggregated </param>
        /// <param name="cultureCode"></param>
        /// <param name="isDailyPrice">
        ///  Volume can be accumulated real-time or at the end of the day. 
        ///  - If data is collected in realtime, 
        ///  updateVolume table is used to culmulated the volume for each day and that will need some more resources.
        ///  - If data is collected at the end of the day, the voulume alredy is the total volume and updateVolume table 
        ///  should not be used to save resources.
        /// </param>
        /// <param name="onAggregateDataFunc">function that was triggered after each agrregation</param>
        public static void AggregatePriceData(data.baseDS.priceDataDataTable priceTbl,  CultureInfo cultureInfo,
                                              OnAggregateData onAggregateDataFunc)
        {
            data.baseDS.priceDataSumDataTable priceSumDataTbl = new data.baseDS.priceDataSumDataTable();
            agrregateStat myAgrregateStat = new agrregateStat();
            myAgrregateStat.maxCount = priceTbl.Count;
            priceTbl.DefaultView.Sort = priceTbl.onDateColumn.ColumnName + "," + priceTbl.stockCodeColumn.ColumnName;
            data.baseDS.priceDataRow priceDataRow;
            
            decimal changeVolume;
            int lastYear = int.MinValue;
            for (int idx = 0; idx < priceTbl.DefaultView.Count; idx++)
            {
                priceDataRow = (data.baseDS.priceDataRow)priceTbl.DefaultView[idx].Row; 
                myAgrregateStat.count = idx;
                if (onAggregateDataFunc != null) onAggregateDataFunc(myAgrregateStat);
                if (myAgrregateStat.cancel)
                {
                    priceSumDataTbl.Clear();
                    break;
                }
                changeVolume = priceDataRow.volume;
                foreach (AppTypes.TimeScale timeScale in AppTypes.myTimeScales)
                {
                    if (timeScale.Type == AppTypes.TimeScaleTypes.RealTime) continue; 
                    AggregatePriceData(priceDataRow, changeVolume, timeScale, cultureInfo, priceSumDataTbl);
                    Application.DoEvents();
                }
                //Update and clear cache to speed up the performance
                if (lastYear != priceDataRow.onDate.Year)
                {
                    application.DbAccess.UpdateData(priceSumDataTbl);
                    priceSumDataTbl.Clear();
                    lastYear = priceDataRow.onDate.Year;
                }
            }
            application.DbAccess.UpdateData(priceSumDataTbl);
        }
コード例 #6
0
ファイル: AppLibs.cs プロジェクト: oghenez/trade-software
 public static void ReAggregatePriceData(string code, CultureInfo stockCulture, OnAggregateData onAggregateDataFunc)
 {
     //Load main  pricedata
     baseDS.priceDataDataTable priceTbl = new databases.baseDS.priceDataDataTable();
     DbAccess.LoadData(priceTbl, AppTypes.MainDataTimeScale.Code, DateTime.MinValue, DateTime.MaxValue, code);
     if (priceTbl == null)
     {
         return;
     }
     //Delete all summ pricedata
     DbAccess.DeletePriceSumData(code);
     ClearLastClosePrices();
     AggregatePriceData(priceTbl, stockCulture, onAggregateDataFunc);
     priceTbl.Dispose();
 }