Example #1
0
        private void dgViewSummary_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            var             row  = dgViewSummary.Rows[e.RowIndex];
            AllTableSummary item = (AllTableSummary)row.DataBoundItem;

            //row.DefaultCellStyle.ForeColor = Color.Red;
            if (item != null && item.LastPrice == 0)
            {
                row.Cells["Last Price"].Style.ForeColor = Color.Red;
            }
            if (item != null && item.TotalVolume == 0)
            {
                row.Cells["Total Volume"].Style.ForeColor = Color.Red;
            }
            if (item != null && item.LastDayVolume == 0)
            {
                row.Cells["Last Day Volume"].Style.ForeColor = Color.Red;
            }
        }
Example #2
0
        // accesses AllTable for passed in share number and determines the
        // Firstday,Lastday and NumberOfTradingDays which it returns in an AllTableSummary object
        internal static AllTableSummary GetAllTableSummaryForShare(int shareNum)
        {
            var    allTablesFolder  = Helper.UserSettings().AllTablesFolder;
            string allTableFilename = allTablesFolder + $"\\alltable_{shareNum}.at";

            var shareSummary = new AllTableSummary(new Share("dontcare", 1));

            //determine First Day, Last Day and number of trading days by inspecting the All-Table file
            using (FileStream fs = new FileStream(allTableFilename, FileMode.Open))
            {
                //read in entire all-table
                var atRows = Helper.DeserializeAllTable <AllTable>(fs).ToArray();

                shareSummary.FirstDay            = atRows[2].Date;
                shareSummary.LastDay             = atRows[atRows.Count() - 1].Date;
                shareSummary.NumberOfTradingDays = (atRows.Count() - 2) / 104;
            }

            return(shareSummary);
        }
Example #3
0
        internal void GenerateAllTableSummaryForGrid(Action <int> progress, List <AllTableSummary> summaries)
        {
            var allTablesFolder = Helper.UserSettings().AllTablesFolder;
            var shareLines      = LocalStore.CreateShareArrayFromShareList();
            int shareCount      = 0;

            foreach (string line in shareLines)
            {
                var    share            = Helper.CreateShareFromLine(line);
                string allTableFilename = allTablesFolder + $"\\alltable_{share.Number}.at";

                //determine First Day, Last Day and number of trading days by inspecting the All-Table file
                using (FileStream fs = new FileStream(allTableFilename, FileMode.Open))
                {
                    //read in entire all-table
                    var atRows  = Helper.DeserializeAllTable <AllTable>(fs).Skip(2).ToArray();
                    var numRows = atRows.Count();

                    var shareSummary = new AllTableSummary(share);
                    shareSummary.FirstDay            = atRows[0].Date;
                    shareSummary.LastDay             = atRows[numRows - 1].Date;
                    shareSummary.LastPrice           = atRows[numRows - 1].FP;
                    shareSummary.TotalVolume         = (uint)atRows.Sum(x => x.FV);
                    shareSummary.AverageDailyVolume  = Convert.ToUInt32(104 * atRows.Average(x => x.FV));
                    shareSummary.LastDayVolume       = (uint)atRows.Skip(numRows - 104).Take(14).Sum(x => x.FV);
                    shareSummary.NumberOfTradingDays = (atRows.Count()) / 104;

                    summaries.Add(shareSummary);
                }
                shareCount++;
                //if (shareCount == 10) break;
                if (progress != null)
                {
                    progress(shareCount);
                }
            }
        }