Example #1
0
        /// <summary>
        /// Returns history requirements for the volatility model expressed in the form of history request
        /// </summary>
        /// <param name="security">The security of the request</param>
        /// <param name="utcTime">The date/time of the request</param>
        /// <returns>History request object list, or empty if no requirements</returns>
        public override IEnumerable <HistoryRequest> GetHistoryRequirements(Security security, DateTime utcTime)
        {
            var barCount       = _window.Size + 1;
            var localStartTime = Time.GetStartTimeForTradeBars(security.Exchange.Hours, utcTime.ConvertFromUtc(security.Exchange.TimeZone), _periodSpan, barCount, security.IsExtendedMarketHours);
            var utcStartTime   = localStartTime.ConvertToUtc(security.Exchange.TimeZone);

            if (SubscriptionDataConfigProvider == null)
            {
                throw new Exception(
                          "RelativeStandardDeviationVolatilityModel.GetHistoryRequirements(): " +
                          "SubscriptionDataConfigProvider was not set."
                          );
            }
            var configurations = SubscriptionDataConfigProvider
                                 .GetSubscriptionDataConfigs(security.Symbol)
                                 .ToList();
            var configuration = configurations.First();

            return(new[]
            {
                new HistoryRequest(utcStartTime,
                                   utcTime,
                                   typeof(TradeBar),
                                   configuration.Symbol,
                                   configurations.GetHighestResolution(),
                                   security.Exchange.Hours,
                                   configuration.DataTimeZone,
                                   configurations.GetHighestResolution(),
                                   configurations.IsExtendedMarketHours(),
                                   configurations.IsCustomData(),
                                   configurations.DataNormalizationMode(),
                                   LeanData.GetCommonTickTypeForCommonDataTypes(typeof(TradeBar), security.Type))
            });
        }
        /// <summary>
        /// Returns history requirements for the volatility model expressed in the form of history request
        /// </summary>
        /// <param name="security">The security of the request</param>
        /// <param name="utcTime">The date/time of the request</param>
        /// <returns>History request object list, or empty if no requirements</returns>
        public override IEnumerable <HistoryRequest> GetHistoryRequirements(Security security, DateTime utcTime)
        {
            if (SubscriptionDataConfigProvider == null)
            {
                throw new InvalidOperationException(
                          "RelativeStandardDeviationVolatilityModel.GetHistoryRequirements(): " +
                          "SubscriptionDataConfigProvider was not set."
                          );
            }

            var configurations = SubscriptionDataConfigProvider
                                 .GetSubscriptionDataConfigs(security.Symbol)
                                 .OrderBy(c => c.TickType)
                                 .ToList();

            return(GetHistoryRequirements(
                       security,
                       utcTime,
                       configurations.GetHighestResolution(),
                       _window.Size + 1));
        }
Example #3
0
        public override IEnumerable <HistoryRequest> GetHistoryRequirements(Security security, DateTime utcTime)
        {
            var configuration = SubscriptionDataConfigProvider.GetSubscriptionDataConfigs(security.Symbol).First();

            return(new[]
            {
                new HistoryRequest(
                    utcTime,
                    utcTime,
                    typeof(TradeBar),
                    configuration.Symbol,
                    configuration.Resolution,
                    security.Exchange.Hours,
                    configuration.DataTimeZone,
                    configuration.Resolution,
                    configuration.ExtendedMarketHours,
                    configuration.IsCustomData,
                    configuration.DataNormalizationMode,
                    LeanData.GetCommonTickTypeForCommonDataTypes(typeof(TradeBar), security.Type)
                    )
            });
        }