Ejemplo n.º 1
0
        private void BtnStartClick(object sender, EventArgs e)
        {
            if (worker.IsBusy)
            {
                // тест в процессе, пользователь пытается остановить тест
                stoppingTest = true;
                return;
            }

            stoppingTest      = false;
            progressBar.Value = 0;
            // сохраним настройки
            UserSettings.Instance.UseTestPeriod  = cbUseSelectedDate.Checked;
            UserSettings.Instance.TestPeriodFrom = dtDateFrom.Value;
            UserSettings.Instance.TestPeriodTo   = dtDateTo.Value;
            UserSettings.Instance.SaveLog        = cbLogTrace.Checked;
            UserSettings.Instance.SaveSettings();

            if (cbUseSelectedDate.Checked)
            {
                robotContext.TimeFrom = dtDateFrom.Value;
                robotContext.TimeTo   = dtDateTo.Value;
            }
            else
            {
                robotContext.TimeFrom = new DateTime(1999, 1, 1, 1, 0, 0);
                robotContext.TimeTo   = DateTime.Now;
                dtDateFrom.Value      = robotContext.TimeFrom;
                dtDateTo.Value        = robotContext.TimeTo;
            }

            robotContext.ClearAllTradeHistory();
            foreach (var robot in robotPortfolioControl.GetUsedRobots())
            {
                robot.Initialize(robotContext, CurrentProtectedContext.Instance);
                robotContext.SubscribeRobot(robot);
            }

            robotContext.LogRobots         = cbLogTrace.Checked;
            robotContext.UpdateTickerCache = cbUpdateQuotes.Checked;
            robotContext.InitiateTest();

            // сменить заголовок кнопки
            btnStart.Text = controlButtonNameStop;

            worker.RunWorkerAsync();
        }
Ejemplo n.º 2
0
        public void TestSetup()
        {
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);
            context = TestRobotUtil.GetRobotContextBacktest(new DateTime(2013, 12, 25), new DateTime(2013, 12, 25).AddDays(30));

            bot = new VoidRobot();
            bot.Graphics.Add(new Cortege2 <string, BarSettings>("EURUSD", new BarSettings
            {
                StartMinute = 0,
                Intervals   = new List <int> {
                    30
                }
            }));
            bot.Initialize(context, CurrentProtectedContext.Instance);

            ExecutablePath.InitializeFake(string.Empty);
            context.SubscribeRobot(bot);
            context.InitiateTest();

            // Инициализация дополнительных объектом, MOCK-и
            QuoteMaker.FillQuoteStorageWithDefaultValues();
        }
Ejemplo n.º 3
0
        private RobotContextBacktest MakeRobotContext(ACCOUNT accountData, List <BaseRobot> robots)
        {
            var timeFrom = testOnly
                ? accountData.TimeCreated
                : accountData.TimeCreated.AddMinutes(rand.Next(60 * 24 * 9));

            try
            {
                var context = new RobotContextBacktest((tickers, end) => { })
                {
                    TimeFrom = timeFrom
                };
                context.TimeFrom = timeFrom;
                context.TimeTo   = endTime;

                context.AccountInfo = new Account
                {
                    Currency = accountData.Currency,
                    Group    = accountData.AccountGroup,
                    Balance  = accountData.Balance,
                    Equity   = accountData.Balance,
                    ID       = accountData.ID
                };
                foreach (var robot in robots)
                {
                    context.SubscribeRobot(robot);
                    robot.Initialize(context, CurrentProtectedContext.Instance);
                }

                context.InitiateTest();
                return(context);
            }
            catch (Exception ex)
            {
                Logger.Error("Error in MakeRobotContext()", ex);
                throw;
            }
        }
Ejemplo n.º 4
0
        public void InitContext()
        {
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);
            context = TestRobotUtil.GetRobotContextBacktest(new DateTime(2013, 12, 25), new DateTime(2013, 12, 25).AddDays(30));

            bot = new RobotMA
            {
                RangeFastMA           = 5,
                RangeSlowMA           = 15,
                DeriveSiteFromHistory = true
            };
            bot.Graphics.Add(new Cortege2 <string, BarSettings>("EURUSD", new BarSettings
            {
                StartMinute = 0,
                Intervals   = new List <int> {
                    30
                }
            }));
            bot.Initialize(context, CurrentProtectedContext.Instance);

            ExecutablePath.InitializeFake(string.Empty);
            context.SubscribeRobot(bot);
            context.InitiateTest();
        }
Ejemplo n.º 5
0
 public void Setup()
 {
     bot.Initialize(context, CurrentProtectedContext.Instance);
     context.SubscribeRobot(bot);
     context.InitiateTest();
 }