Example #1
0
 private void frmStockAnalysis_Load(object sender, EventArgs e)
 {
     lblInformations.Text  = string.Empty;
     stockAnaliysisManager = new StockAnalysisManager(request);
     stockAnaliysisManager.RefreshList();
     gridFill(stockAnaliysisManager);
 }
Example #2
0
        private void frmStockAnalysis_Load(object sender, EventArgs e)
        {
            var chartType = SeriesChartType.Spline;

            lvList.Items.Clear();

            chartPeriodGain.Series.Clear();
            Series totalGainSeries    = new Series();
            Series totalConstSeries   = new Series();
            Series expectedGainSeries = new Series();

            totalConstSeries.ChartType         = chartType;
            totalConstSeries.MarkerBorderColor = Color.MediumVioletRed;
            totalConstSeries.MarkerColor       = Color.MediumVioletRed;
            totalConstSeries.Color             = Color.Crimson;
            totalConstSeries.MarkerSize        = 5;
            totalConstSeries.MarkerStep        = 1;
            totalConstSeries.MarkerBorderWidth = 5;
            totalConstSeries.BorderWidth       = 3;
            totalConstSeries.MarkerStyle       = MarkerStyle.Circle;
            totalConstSeries.Name = Translate.GetMessage("const");

            totalGainSeries.ChartType         = chartType;
            totalGainSeries.MarkerBorderColor = Color.SteelBlue;
            totalGainSeries.MarkerColor       = Color.SteelBlue;
            totalGainSeries.Color             = Color.RoyalBlue;
            totalGainSeries.MarkerSize        = 5;
            totalGainSeries.BorderWidth       = 3;
            totalGainSeries.MarkerStep        = 1;
            totalGainSeries.MarkerBorderWidth = 5;
            totalGainSeries.MarkerStyle       = MarkerStyle.Circle;
            totalGainSeries.Name = Translate.GetMessage("gain");

            expectedGainSeries.ChartType         = chartType;
            expectedGainSeries.MarkerBorderColor = Color.Goldenrod;
            expectedGainSeries.MarkerColor       = Color.Goldenrod;
            expectedGainSeries.Color             = Color.Gold;
            expectedGainSeries.MarkerSize        = 5;
            expectedGainSeries.BorderWidth       = 3;
            expectedGainSeries.MarkerStep        = 1;
            expectedGainSeries.MarkerBorderWidth = 5;
            expectedGainSeries.MarkerStyle       = MarkerStyle.Circle;
            expectedGainSeries.Name = Translate.GetMessage("expected-gain");
            List <StockAnalysisManagerList> list = new List <StockAnalysisManagerList>();


            foreach (var period in Session.Entities.GetPeriods().Where(c => c.StartDate < DateTime.Now))
            {
                StockAnalysisManager analysisManager = new StockAnalysisManager(new StockAnalysisRequest
                {
                    Period = period
                });
                analysisManager.RefreshList();
                list.Add(new StockAnalysisManagerList {
                    Period = period, StockAnalysisManager = analysisManager
                });
            }

            decimal totalGain = 0;

            foreach (var item in list.Where(c => !c.Period.IsPublic).OrderBy(c => c.Period.StartDate))
            {
                totalGain += item.StockAnalysisManager.TotalGain;
                item.CumulativeEndOfDay = totalGain + item.StockAnalysisManager.ExpectedGain;
            }

            foreach (var item in list.OrderByDescending(c => c.Period.StartDate))
            {
                var li = new ListViewItem();
                li.Text = item.Period.PeriodId.ToString();
                li.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Name = "month",
                    Text = item.Period.PeriodName
                });
                li.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Name = "gain",
                    Text = item.StockAnalysisManager.TotalGain.ToMoneyStirng(2)
                });
                li.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Name = "const",
                    Text = item.StockAnalysisManager.TotalConst.ToMoneyStirng(2)
                });
                li.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Name = "expectedGain",
                    Text = item.StockAnalysisManager.ExpectedGain.ToMoneyStirng(2)
                });
                li.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Name = "endOfDay",
                    Text = (item.StockAnalysisManager.TotalGain + item.StockAnalysisManager.ExpectedGain).ToMoneyStirng(2)
                });
                li.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Name = "cumulativeEndOfDay",
                    Text = item.Period.IsPublic ? string.Empty : item.CumulativeEndOfDay.ToMoneyStirng(2)
                });
                if (item.Period.IsPublic)
                {
                    li.BackColor = Color.DarkSlateGray;
                }

                lvList.Items.Add(li);
            }

            foreach (var item in list.Where(c => !c.Period.IsPublic).OrderBy(c => c.Period.StartDate))
            {
                DataPoint pointTotalAgain = new DataPoint();
                pointTotalAgain.SetValueXY(item.Period.PeriodName, item.StockAnalysisManager.TotalGain);
                pointTotalAgain.ToolTip = $"{Session.DefaultAccount.MoneyType.MoneyTypeToString()} {item.StockAnalysisManager.TotalGain.ToMoneyStirng(2)}";
                totalGainSeries.Points.Add(pointTotalAgain);
                DataPoint pointTotalConst = new DataPoint();
                pointTotalConst.SetValueXY(item.Period.PeriodName, item.StockAnalysisManager.TotalConst);
                pointTotalConst.ToolTip = $"{Session.DefaultAccount.MoneyType.MoneyTypeToString()} {item.StockAnalysisManager.TotalConst.ToMoneyStirng(2)}";
                totalConstSeries.Points.Add(pointTotalConst);
                DataPoint pointExceptedGain = new DataPoint();
                pointExceptedGain.SetValueXY(item.Period.PeriodName, item.StockAnalysisManager.ExpectedGain);
                pointExceptedGain.ToolTip = $"{Session.DefaultAccount.MoneyType.MoneyTypeToString()} {item.StockAnalysisManager.ExpectedGain.ToMoneyStirng(2)}";
                expectedGainSeries.Points.Add(pointExceptedGain);
            }

            chartPeriodGain.Series.Add(totalGainSeries);
            chartPeriodGain.Series.Add(totalConstSeries);
            series.Add(totalGainSeries);
            series.Add(totalConstSeries);
            series.Add(expectedGainSeries);
        }