예제 #1
0
        /// <summary>
        /// Выполняет генерацию оптимального портфеля по Марковицу
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void марковицItem_Click(object sender, EventArgs e)
        {
            double mp = double.Parse(this.mpText.Text);

            if (table != null)
            {
                double   Dp;
                double[] x = Analysis.Markowitz(table, mp, out Dp);


                MessageBox.Show("Анализ успешно выполнен", "Отчет", MessageBoxButtons.OK, MessageBoxIcon.Information);

                ChartForm f = new ChartForm();

                var points = f.MainChart.Series[0].Points;
                points.Clear();
                for (int i = 0; i < x.Length; i++)
                {
                    points.AddY(x[i]);
                }
                f.ShowDialog();
                DpText.Text = string.Format("{0:f4}", Dp);
                GridXResult(x);
            }
        }
예제 #2
0
        private void шарпItem_Click(object sender, EventArgs e)
        {
            if (table != null)
            {
                double mp = double.Parse(this.mpText.Text);
                openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                openFile.Filter           = "csv files (*.csv)|*.txt|All files (*.*)|*.*";
                openFile.FilterIndex      = 2;
                openFile.RestoreDirectory = true;
                openFile.FileName         = "PriceI.csv";

                //Цены доп портфеля
                double[] PriceI = new double[table.RecordCount()];
                if (openFile.ShowDialog() == DialogResult.OK)
                {
                    using (StreamReader sr = new StreamReader(openFile.FileName))
                    {
                        for (int i = 0; i < table.RecordCount(); i++)
                        {
                            PriceI[i] = double.Parse(sr.ReadLine());
                        }
                    }


                    //Если цены для эталонного портфеля получены ...
                    double   Dp;
                    double[] x = Analysis.Sharp(table, PriceI, mp, out Dp);


                    MessageBox.Show("Анализ успешно выполнен", "Отчет", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    ChartForm f = new ChartForm();

                    var points = f.MainChart.Series[0].Points;
                    points.Clear();
                    for (int i = 0; i < x.Length; i++)
                    {
                        points.AddY(x[i]);
                    }
                    f.ShowDialog();
                    DpText.Text = string.Format("{0:f4}", Dp);
                    GridXResult(x);
                }
            }
        }