private CommandHandler(IConnector connector)
        {
            _connector = connector;
            var logger = new FileLogListener
            {
                Append          = true,
                MaxLength       = 2048000,
                FileName        = "{0:00}_{1:00}_{2:00}_log.txt".Put(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second),
                SeparateByDates = SeparateByDateModes.FileName,
                LogDirectory    = "logs"
            };

            _logManager = new LogManager();

            _userPositions = new Dictionary <string, UserPosition>();

            _messageManager              = new MessageManager();
            _messageManager.AutoMessage += DoAutoGeneralInfo;

            UserPosition.LoadFromXml()?.ForEach(up => { _userPositions.Add(up.SecCode, up); });

            _logManager.Listeners.Add(logger);
            _logManager.Sources.Add(_connector);
        }
        private void DoConnectCmd()
        {
            if (_connector.ConnectionState == ConnectionStates.Connected)
            {
                _messageManager.ProceedAnswer("already connected.");
                return;
            }

            _connector.Connected += () =>
            {
                _messageManager.ProceedAnswer("connected (success), loading securities, pls wait...");
                _dataManager = new DataManager(_connector);
            };

            _connector?.Connect();

            Task.Run(() =>
            {
                try
                {
                    Thread.Sleep(5000); //dunno what to do

                    var tempSecurityMap      = new SynchronizedDictionary <string, Security>();
                    var cannotReadCounter    = 0;
                    var alreadyLoadedCounter = 0;

                    _connector.Securities.ForEach(s =>
                    {
                        if (s.ExpiryDate == null || s.Type != SecurityTypes.Future && s.Type != SecurityTypes.Option)
                        {
                            cannotReadCounter++;
                            return;
                        }

                        var key = _dataManager.GetSecurityStringRepresentation(s);

                        if (tempSecurityMap.ContainsKey(key))
                        {
                            alreadyLoadedCounter++;
                        }
                        else
                        {
                            tempSecurityMap.Add(key, s);
                        }
                    });

                    _dataManager.MappedSecurities = tempSecurityMap;

                    _messageManager.ProceedAnswer($"couldn't read instruments: {cannotReadCounter}", ConsoleColor.Red, false);
                    _messageManager.ProceedAnswer($"attempts to load more than twice: {alreadyLoadedCounter}", ConsoleColor.Red, false);

                    _dataManager.UnderlyingAsset = _dataManager.LookupThroughExistingSecurities(
                        ConfigManager.GetInstance().GetSettingValue(UserConfigs.Asset.ToString()));

                    _dataManager.RegisterMappedUndAssetsSecuruties();

                    _messageManager.ProceedAnswer($"{_dataManager.MappedSecurities.Count} securities loaded.");

                    _connector.NewMyTrade += mt =>
                    {
                        var secCode = mt.Trade.Security.Code;
                        var price   = mt.Trade.Price;
                        var size    = mt.Trade.Volume;
                        var side    = mt.Order.Direction;

                        if (!_userPositions.ContainsKey(secCode))
                        {
                            var userPosNew = new UserPosition(secCode);
                            _userPositions.Add(secCode, userPosNew);
                        }

                        _userPositions[secCode].AddNewDeal(side, price, size);

                        UserPosition.SaveToXml(_userPositions.Values.ToList());

                        _messageManager.ProceedAnswer(MessageManager.AlignString(new string[]
                        {
                            "NEW TRADE [",
                            $"side: {mt.Order.Direction}",
                            $"size: {mt.Trade.Volume}",
                            $"price: {mt.Trade.Price}",
                            $"sec: {mt.Trade.Security.Code}",
                            " ], deal saved"
                        }), ConsoleColor.Magenta);
                    };

                    _messageManager.ProceedAnswer("Print 'timer' to enable/disable auto-print-information about positions.", ConsoleColor.Yellow);
                    DoStatusCmd();
                }
                catch (Exception e1)
                {
                    _messageManager.ProceedAnswer($"unknown exception: {e1.Message}", ConsoleColor.Red);
                }
            });
        }