예제 #1
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public DataHandler()
        {
            try
            {
                _classLogger = new AsyncClassLogger("DataHandler");
                _classLogger.SetLoggingLevel();
                //set logging path
                string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
                              "\\TradeHub Logs\\Client";
                _classLogger.LogDirectory(path);

                _fetchMarketData = new FetchData(new ReadMarketData(_classLogger), _classLogger);

                // Initialize Lists
                BarSubscriptionList  = new List <string>();
                TickSubscriptionList = new List <string>();

                _fetchMarketData.InitializeDisruptor(new IEventHandler <MarketDataObject>[] { this });
                _fetchMarketData.HistoricalDataFired += HistoricDataArrived;
            }
            catch (Exception exception)
            {
                _classLogger.Error(exception, _type.FullName, "DataHandler");
            }
        }
예제 #2
0
        /// <summary>
        /// Argument Constructor
        /// </summary>
        /// <param name="eventHandler">Event handler which will receive requested data</param>
        /// <param name="localPersistance">Indicates whether the data to be saved locally on initial request</param>
        public DataHandler(IEventHandler <MarketDataObject>[] eventHandler, bool localPersistance = false)
        {
            try
            {
                _classLogger = new AsyncClassLogger("SimulatedDataHandler");
                // Set logging level
                _classLogger.SetLoggingLevel();
                //set logging path
                _classLogger.LogDirectory(DirectoryStructure.CLIENT_LOGS_LOCATION);

                _persistanceDataCount = 0;
                _localPersistance     = localPersistance;
                _localPersistanceData = new SortedDictionary <int, MarketDataObject>();
                _tasksCollection      = new ConcurrentBag <Task>();

                _fetchMarketData = new FetchData(new ReadMarketData(_classLogger), _classLogger);

                // Initialize Lists
                BarSubscriptionList  = new List <string>();
                TickSubscriptionList = new List <string>();

                _fetchMarketData.InitializeDisruptor(eventHandler);
                _fetchMarketData.HistoricalDataFired += HistoricDataArrived;
            }
            catch (Exception exception)
            {
                _classLogger.Error(exception, _type.FullName, "DataHandler");
            }
        }