public MainWindowViewModel()
        {
            PortIb           = Convert.ToInt32(Configuration.Instance["PortIb"]);
            ConnectionString = Configuration.Instance["ConnectionString"];
            LogSymbols.Add("Willkommen! Enjoy the day (-:");
            LogFundamentals.Add("Willkommen! Enjoy the day (-:");
            BackgroundLog = Brushes.White;

            InitDatesCombobok();
            InitExchangeCombobox();
            InitExchangeFmpCombobox();

            UpdateDbState();
            InventoryText = GenerateInventoryText();
            SelectTop1000 = true;
            UpdateCompaniesForFundamenatals(SelectTop1000);

            CommandConnectToIb        = new RelayCommand(async(p) => await CommandConnectToIbAsync(p));
            CommandImportContracts    = new RelayCommand(async(p) => await CommandImportContractsAsync(p));
            CommandImportFundamentals = new RelayCommand(async(p) => await CommandImportFundamentalsAsync(p));

            IbClient.Instance.NextValidId      += ResponseHandlerNextValidId;
            IbClient.Instance.ConnectionClosed += ResponseHandlerConnectionClosed;
            IbClient.Instance.SymbolSamples    += ResponseHandlerSymbolSamples;
            IbClient.Instance.FundamentalData  += ResponseHandlerFundamentalData;
        }
        /// <summary>
        /// ResponseHandlerNextValidId
        /// </summary>
        /// <param name="obj"></param>
        private void ResponseHandlerNextValidId(IBSampleApp.messages.ConnectionStatusMessage obj)
        {
            BackgroundLog = Brushes.White;
            var message = string.Empty;

            if (obj.IsConnected)
            {
                ConnectedToIb = true;
                message       = "OK! Connected to IB server.";
            }
            else
            {
                ConnectedToIb = false;
                message       = "ERROR! error connecting to IB server.";
            }

            LogSymbols.Add(message);
            LogFundamentals.Add(message);
        }
        /// <summary>
        /// ConnectToIbAsync
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        private async Task CommandConnectToIbAsync(object p)
        {
            LogFundamentals.Clear();
            LogSymbols.Clear();
            BackgroundLog = Brushes.Gray;

            await Task.Run(() =>
            {
                int portIb  = 0;
                string host = string.Empty;
                int delay   = 0;
                int timeout = 0;
                Dispatcher.Invoke(() =>
                {
                    portIb  = PortIb;
                    host    = Configuration.Instance["Localhost"];
                    delay   = Convert.ToInt32(Configuration.Instance["DelayFundamentals"]);
                    timeout = Convert.ToInt32(Configuration.Instance["TimeoutIbConnection"]);
                });

                IbClient.Instance.Connect(host, portIb, 1);
            });
        }