Example #1
0
        /// <summary>
        /// Processes the specified data points.
        /// </summary>
        /// <param name="dataPoints">The data points.</param>
        private void Process(IEnumerable <DataPoint> dataPoints)
        {
            //Convert, aggregate and save
            foreach (var datapoint in dataPoints.OrderBy(x => x.Occured))
            {
                //Set meta-data
                string ticker = DataFeed.GetFeedTicker(datapoint.Ticker);
                if (_date == 0)
                {
                    _date = int.Parse(datapoint.Occured.ToString("yyyyMMdd"));
                }

                //Check for aggregation
                if (!_minBarAggregators.TryGetValue(ticker, out TickAggregator tickAggregator))
                {
                    _minBarWriters[ticker]     = new DataWriter(Machine.Instance.GetPath(_options.OutputFolder), ticker, _date, "1m", DataType.TradeBar);
                    _minBarAggregators[ticker] = new TickAggregator(TimeSpan.FromMinutes(1));
                    _minBarAggregators[ticker].DataAggregated += (sender, data) => _minBarWriters[ticker].Feed(data);
                    tickAggregator = _minBarAggregators[ticker];
                }

                //Check for tick writer
                if (!_tickWriters.TryGetValue(ticker, out DataWriter tickwriter))
                {
                    tickwriter           = new DataWriter(Machine.Instance.GetPath(_options.OutputFolder), ticker, _date, "1t", DataType.Tick);
                    _tickWriters[ticker] = tickwriter;
                }

                //Add data
                tickAggregator.Feed(datapoint);
                tickwriter.Feed(datapoint);
            }
        }
Example #2
0
 /// <summary>
 /// Gets the name of ticker in the feed.
 /// </summary>
 /// <param name="ticker">The ticker.</param>
 /// <returns></returns>
 public override string GetFeedTicker(TickerSymbol ticker) =>
 _baseDataFeed.GetFeedTicker(ticker);