public HistoricalDataBroker(IContinuousFuturesBroker cfBroker, IDataStorage localStorage, IEnumerable <QDMS.IHistoricalDataSource> additionalSources = null) { if (cfBroker == null) { throw new ArgumentNullException("cfBroker"); } if (localStorage == null) { throw new ArgumentNullException("localStorage"); } _dataStorage = localStorage; DataSources = new ObservableDictionary <string, QDMS.IHistoricalDataSource> { /* * { "Interactive Brokers", new IB(Properties.Settings.Default.histClientIBID) }, * { "Yahoo", new Yahoo() }, * { "Quandl", new Quandl() }, * { "FRED", new FRED() }, * { "Google", new Google() } */ }; //add the continuous futures broker to the data sources DataSources.Add("ContinuousFuturesBroker", cfBroker); //add additional sources if (additionalSources != null) { foreach (IHistoricalDataSource ds in additionalSources) { if (!DataSources.ContainsKey(ds.Name)) { DataSources.Add(ds.Name, ds); } } } foreach (IHistoricalDataSource ds in DataSources.Values) { ds.Error += DatasourceError; ds.HistoricalDataArrived += ExternalHistoricalDataArrived; ds.Disconnected += SourceDisconnects; } _dataStorage.Error += DatasourceError; _dataStorage.HistoricalDataArrived += LocalStorageHistoricalDataArrived; _connectionTimer = new Timer(10000); _connectionTimer.Elapsed += ConnectionTimerElapsed; _connectionTimer.Start(); _originalRequests = new ConcurrentDictionary <int, HistoricalDataRequest>(); _subRequests = new ConcurrentDictionary <int, List <HistoricalDataRequest> >(); _usedIDs = new HashSet <int>(); _requestHandlerThread = new Thread(RequestHandler) { Name = "HDBPoller" }; _requestHandlerThread.Start(); TryConnect(); }