Esempio n. 1
0
        private void RunTest(TradeParams tradeParams, Configurator configurator, TradesPrinter printer)
        {
            tradeParams.Validate();

            var advisor = new TradeAdvisor(configurator.Repository.Days.First().FiveMins);
            var robot = new RobotContext(tradeParams, configurator.Factory, advisor);
            var results = configurator.GetTradeResults();

            //foreach (var day in repository.Days)
            foreach (var day in configurator.Repository.Days.Skip(1))    //TODO перебирать параметры по абсолютному значению, а затем искать регрессию одних на другие
            {
                foreach (var candle in day.FiveMins)
                {
                    var dealEvent = robot.Process(candle) as DealEvent;
                    if (dealEvent != null)
                    {
                        results.AddDeal(dealEvent.Deal);
                    }
                }
                var ev = robot.StopTrading() as DealEvent;
                if (ev != null)
                {
                    results.AddDeal(ev.Deal);
                }
                //printer.PrintDepoWithParamsName(tradeParams, results);

                Assert.That(results.DealsAreClosed);
                robot.Reset();
            }

            //File.WriteAllLines("out.txt", results.GetDepositSizes().Select(s => (s - 30000).ToString()));
            printer.AddRow(tradeParams, results);
        }
Esempio n. 2
0
        public void MainTest(string filename)
        {
            var configurator = new Configurator(filename);
            var printer = configurator.Printer;

            configurator.Executor.Execute(tp => RunTest(tp, configurator, printer));
            printer.PrintTable("MainTest");
        }
Esempio n. 3
0
 public void TestConfigurator()
 {
     var cr = new Configurator("Configs/main.xml");
     cr.Executor.Execute(tp => Console.WriteLine("{0}, {1}, {2}", tp.PegtopSize, tp.TrailingStopPercent, tp.StopLoss));
 }