Esempio n. 1
0
        /// <summary>
        /// Get historical data enumerable for a single symbol, type and resolution given this start and end time (in UTC).
        /// </summary>
        /// <param name="symbol">Symbol for the data we're looking for.</param>
        /// <param name="resolution">Resolution of the data request</param>
        /// <param name="startUtc">Start time of the data in UTC</param>
        /// <param name="endUtc">End time of the data in UTC</param>
        /// <returns>Enumerable of base data for this symbol</returns>
        public IEnumerable <BaseData> Get(Symbol symbol, Resolution resolution, DateTime startUtc, DateTime endUtc)
        {
            if (!(resolution == Resolution.Daily || resolution == Resolution.Minute))
            {
                throw new NotSupportedException("Resolution not available: " + resolution);
            }

            if (endUtc < startUtc)
            {
                throw new ArgumentException("The end date must be greater or equal than the start date.");
            }

            var historyRequests = new[] {
                new HistoryRequest(startUtc,
                                   endUtc,
                                   typeof(QuoteBar),
                                   symbol,
                                   resolution,
                                   SecurityExchangeHours.AlwaysOpen(TimeZones.EasternStandard),
                                   DateTimeZone.Utc,
                                   resolution,
                                   false,
                                   false,
                                   DataNormalizationMode.Adjusted,
                                   TickType.Quote)
            };

            foreach (var slice in _handler.GetHistory(historyRequests, TimeZones.EasternStandard))
            {
                yield return(slice[symbol]);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get historical data enumerable for a single symbol, type and resolution given this start and end time (in UTC).
        /// </summary>
        /// <param name="dataDownloaderGetParameters">model class for passing in parameters for historical data</param>
        /// <returns>Enumerable of base data for this symbol</returns>
        public IEnumerable <BaseData> Get(DataDownloaderGetParameters dataDownloaderGetParameters)
        {
            var symbol     = dataDownloaderGetParameters.Symbol;
            var resolution = dataDownloaderGetParameters.Resolution;
            var startUtc   = dataDownloaderGetParameters.StartUtc;
            var endUtc     = dataDownloaderGetParameters.EndUtc;
            var tickType   = dataDownloaderGetParameters.TickType;

            if (tickType != TickType.Trade)
            {
                yield break;
            }

            if (!(resolution == Resolution.Daily || resolution == Resolution.Minute))
            {
                throw new NotSupportedException("Resolution not available: " + resolution);
            }

            if (endUtc < startUtc)
            {
                throw new ArgumentException("The end date must be greater or equal than the start date.");
            }

            var historyRequests = new[] {
                new HistoryRequest(startUtc,
                                   endUtc,
                                   typeof(TradeBar),
                                   symbol,
                                   resolution,
                                   SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork),
                                   TimeZones.NewYork,
                                   resolution,
                                   true,
                                   false,
                                   DataNormalizationMode.Raw,
                                   TickType.Trade)
            };

            foreach (var slice in _handler.GetHistory(historyRequests, TimeZones.EasternStandard))
            {
                yield return(slice[symbol]);
            }
        }