예제 #1
0
        private async void buttonStart_Click(object sender, EventArgs e)
        {
            TrainerWindow trainer   = new TrainerWindow();
            DateTime      startDate = dateTimePickerStart.Value;
            Stock         stock     = new Stock(textBoxStock.Text);

            if (checkBoxRandomStartDate.Checked)
            {
                Random r         = new Random();
                int    totalDays = (dateTimePickerStart.MaxDate - dateTimePickerStart.MinDate).Days;
                startDate = dateTimePickerStart.MinDate.AddDays(r.Next(0, totalDays - 90));
                StockData data = await StockDataBase.Get(stock, Api.Interval.Daily);

                startDate = data.FindClosestTradeDay(startDate);
            }
            if (OptionChain.DataAvailible(stock, startDate))
            {
                trainer.Show((double)numericUpDown1.Value, startDate, new Stock(textBoxStock.Text));
                this.Close();
            }
        }