public Configurator(string configsName, MainWindow window)
        {
            var document = XDocument.Load(configsName);

            var eventBus = new EventBus();

            InitLogs(window);
            InitConnector(document.Descendants("Connection").Single());

            var factory = GetFactory(document.Descendants("Types").Single());
            var tradeParams = GetParams(document.Descendants("TradeParams").Single());

            var currentDayCandles = Connector.GetCurrentDayCandles();
            var advisor = new TradeAdvisor(currentDayCandles);	//TODO больше истории

            RobotContext = new RobotContext(tradeParams, factory, advisor, currentDayCandles);
            InitTradeController(document.Descendants("TradeController").Single(), eventBus,
                LogManager.Configuration.Variables["WorkingDirectory"]);
        }
        public void TestFireEvent()
        {
            EventBus eb = new EventBus();
            int counter = 0;
            eb.AddCallback(typeof(DealEvent), ev => { ++counter; });
            eb.AddCallback(typeof(StopLossEvent), ev => { ++counter; });
            eb.FireEvent(new StopLossEvent(new Deal(0, DateTime.Now, false)));
            Assert.That(counter == 1);
            eb.AddCallback(typeof(StopLossEvent), ev => { ++counter; });
            eb.FireEvent(new StopLossEvent(new Deal(0, DateTime.Now, false)));
            Assert.That(counter == 3);

            eb.FireEvent(new DealEvent(new Deal(0, DateTime.Now, false)));
            Assert.That(counter == 4);
        }
        private void InitTradeController(XElement controllerNode, EventBus eventBus, string workingDirectory)
        {
            var updatePeriod = (int)controllerNode.Descendants("UpdatePeriod").Single();
            var serverCooldownPeriod = (int)controllerNode.Descendants("ServerCooldownPeriod").Single();
            var tradeStartTime = (TimeSpan)controllerNode.Descendants("TradeStartTime").Single();

            TradeController = new TradeController(eventBus, Connector, RobotContext, workingDirectory, updatePeriod, serverCooldownPeriod, tradeStartTime);
        }