private Task DownloadTask(Asset[] selectedAssets, string path, int period)
 {
     return(Task.Run(() =>
     {
         ClassAssistant.DownloadAllAssets(selectedAssets, path, period, false);
     }));
 }
Example #2
0
        private void checkBox1_index_CheckedChanged(object sender, EventArgs e)
        {
            GraphPane pane = zGC.GraphPane;

            if (checkBox1_index.Checked)
            {
                Asset[] a = new Asset[1];
                a[0] = new Asset("MICEXINDEXCF", "MICEX", 13851);
                ClassAssistant.DownloadAllAssets(a, path, year + 1, false);
                Dictionary <double, double> profitIndex = new Dictionary <double, double>();
                double[] y = ClassAssistant.ReadAssets(path + a[0].Ticker + ".txt", weeks);
                for (int i = 0; i < y.Length; i++)
                {
                    profitIndex.Add(x[i], y[i]);
                }

                double[] y_profit = new double[y.Length];
                y_profit[0] = 0;
                for (int i = 1; i < y_profit.Length; i++)
                {
                    y_profit[i] = ((y[i] / y[0]) - 1) * 100;
                }

                double t   = (y[y.Length - 1] - y[0]) / y[0];
                double ddr = 0;
                Drawdown(profitIndex, out ddr);

                label_i.Visible        = true;
                label_indProfit.Text   = Math.Round(t * 100, 2).ToString() + "%";
                label_indDrowdown.Text = Math.Round(ddr, 2).ToString() + "%";

                index = pane.AddCurve("ММВБ", x, y_profit, Color.Blue, SymbolType.Square);
                index.Symbol.Fill.Type = FillType.Solid;
                CurveList cl = pane.CurveList;
                zGC.AxisChange();
                zGC.Invalidate();
            }
            else
            {
                pane.CurveList.Remove(index);
                zGC.AxisChange();
                zGC.Invalidate();
                label_i.Visible        = false;
                label_indProfit.Text   = "";
                label_indDrowdown.Text = "";
            }
        }
Example #3
0
        private Task Download(List <Asset>[] lst, string path, int period)
        {
            return(Task.Run(() =>
            {
                //ClassAssistant.DownloadAllAssets(allAssets, path, period, false);
                Asset[] asset1 = lst[0].ToArray();
                Asset[] asset2 = lst[1].ToArray();
                Asset[] asset3 = lst[2].ToArray();
                Asset[] asset4 = lst[3].ToArray();

                try
                {
                    Task t1 = Task.Factory.StartNew(() =>
                    {
                        ClassAssistant.DownloadAllAssets(asset1, path, period, false);
                    });

                    Task t2 = Task.Factory.StartNew(() =>
                    {
                        ClassAssistant.DownloadAllAssets(asset2, path, period, false);
                    });

                    Task t3 = Task.Factory.StartNew(() =>
                    {
                        ClassAssistant.DownloadAllAssets(asset3, path, period, false);
                    });

                    Task t4 = Task.Factory.StartNew(() =>
                    {
                        ClassAssistant.DownloadAllAssets(asset4, path, period, false);
                    });

                    Task.WaitAll(t1, t2, t3, t4);
                }
                catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.InnerException); }
            }));
        }