Exemplo n.º 1
0
        private void trackBar_period_MouseLeave(object sender, EventArgs e)
        {
            if (isChange)
            {
                isChange = false;

                /*
                 * List<Asset>[] l = ClassAssistant.FillQueue(assets);
                 * toolStripStatusLabel.Text = "Обновляем волатильность и среднюю доходность...";
                 *
                 * await VolatilityTask(dataPath, l, trackBar_period.Value);
                 *
                 * //  list = list.OrderBy(x => x.Name).ToList();
                 * DoTable(list);
                 */

                assets = ClassAssistant.DoAssetsArray(Program.path + "\\" + trackBar_period.Value + ".txt");
                List <Asset> lst = new List <Asset>();
                foreach (var a in list)
                {
                    for (int i = 0; i < assets.Length; i++)
                    {
                        if (assets[i].Name == a.Name)
                        {
                            lst.Add(assets[i]);
                            break;
                        }
                    }
                }
                list = lst;
                DoTable(list);

                if (dataGridView2.Rows.Count != 0 && dataGridView1.RowCount != 0)
                {
                    cancelToken.Cancel(true);
                    cancelToken = new CancellationTokenSource();
                    int     i        = 0;
                    Asset[] selected = new Asset[dataGridView2.Rows.Count];
                    foreach (DataGridViewRow t in dataGridView2.Rows)
                    {
                        Asset a = (Asset)t.Cells[0].Value;
                        selected[i] = a;
                        i++;
                    }
                    CorrelationTask(selected);
                }
            }
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                dataPath = Program.path + "\\data.txt";
                ClassAssistant.DownloadData(dataPath);

                dataGridView1.AllowUserToOrderColumns = true;
                dataGridView1.SelectionMode           = DataGridViewSelectionMode.FullRowSelect;
                assets = ClassAssistant.DoAssetsArray(Application.StartupPath + "\\assets.txt");
                list   = assets.ToList <Asset>();
                list   = list.OrderBy(x => x.Name).ToList();
                if (File.Exists(Application.StartupPath + "\\options.txt"))
                {
                    using (StreamReader sr = new StreamReader(Application.StartupPath + "\\options.txt", Encoding.GetEncoding(1251)))
                    {
                        string[] text = sr.ReadToEnd().Split('\n');
                        trackBar_period.Value = Convert.ToInt32(text[0].Split('=')[1]);
                        for (int i = 1; i < text.Length - 1; i++)
                        {
                            string[] line = text[i].Split(';');
                            foreach (var a in assets)
                            {
                                if (a.Name == line[0])
                                {
                                    dataGridView2.Rows.Add(a, Convert.ToDouble(line[1].Replace('.', ',')));
                                    list.Remove(a);
                                    break;
                                }
                            }
                        }
                    }
                }


                DoTable(list);
                try
                {
                    ClassAssistant.ReadCapitalization(list, 2017, Application.StartupPath);
                }
                catch (FileNotFoundException) { MessageBox.Show("Файл с данными о капитализации не найден!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                DoTable(list);

                RefreshParameters();

                if (dataGridView2.Rows.Count != 0 && dataGridView1.RowCount != 0)
                {
                    cancelToken.Cancel(true);
                    cancelToken = new CancellationTokenSource();
                    int     i        = 0;
                    Asset[] selected = new Asset[dataGridView2.Rows.Count];
                    foreach (DataGridViewRow t in dataGridView2.Rows)
                    {
                        Asset a = (Asset)t.Cells[0].Value;
                        selected[i] = a;
                        i++;
                    }
                    CorrelationTask(selected);
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                MessageBox.Show("Файл с данными об акциях не найден!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }