当前位置: 首页>>代码示例>>C#>>正文


C# Data.BaseData类代码示例

本文整理汇总了C#中QuantConnect.Data.BaseData的典型用法代码示例。如果您正苦于以下问题:C# BaseData类的具体用法?C# BaseData怎么用?C# BaseData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BaseData类属于QuantConnect.Data命名空间,在下文中一共展示了BaseData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ZipEntryNameSubscriptionFactory

 /// <summary>
 /// Initializes a new instance of the <see cref="ZipEntryNameSubscriptionFactory"/> class
 /// </summary>
 /// <param name="config">The subscription's configuration</param>
 /// <param name="dateTime">The date this factory was produced to read data for</param>
 /// <param name="isLiveMode">True if we're in live mode, false for backtesting</param>
 public ZipEntryNameSubscriptionFactory(SubscriptionDataConfig config, DateTime dateTime, bool isLiveMode)
 {
     _config = config;
     _dateTime = dateTime;
     _isLiveMode = isLiveMode;
     _factory = (BaseData) Activator.CreateInstance(config.Type);
 }
开发者ID:kaffeebrauer,项目名称:Lean,代码行数:13,代码来源:ZipEntryNameSubscriptionFactory.cs

示例2: TextSubscriptionFactory

 /// <summary>
 /// Initializes a new instance of the <see cref="TextSubscriptionFactory"/> class
 /// </summary>
 /// <param name="config">The subscription's configuration</param>
 /// <param name="date">The date this factory was produced to read data for</param>
 /// <param name="isLiveMode">True if we're in live mode, false for backtesting</param>
 public TextSubscriptionFactory(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
 {
     _date = date;
     _config = config;
     _isLiveMode = isLiveMode;
     _factory = (BaseData) ObjectActivator.GetActivator(config.Type).Invoke(new object[0]);
 }
开发者ID:neosb,项目名称:Lean,代码行数:13,代码来源:TextSubscriptionFactory.cs

示例3: Process

 /// <summary>
 /// Invoked for each piece of data from the source file
 /// </summary>
 /// <param name="data">The data to be processed</param>
 public void Process(BaseData data)
 {
     if (_predicate(data))
     {
         _processor.Process(data);
     }
 }
开发者ID:kaffeebrauer,项目名称:Lean,代码行数:11,代码来源:FilteredDataProcessor.cs

示例4: RequiresFillForwardData

        /// <summary>
        /// Determines whether or not fill forward is required, and if true, will produce the new fill forward data
        /// </summary>
        /// <param name="fillForwardResolution"></param>
        /// <param name="previous">The last piece of data emitted by this enumerator</param>
        /// <param name="next">The next piece of data on the source enumerator, this may be null</param>
        /// <param name="fillForward">When this function returns true, this will have a non-null value, null when the function returns false</param>
        /// <returns>True when a new fill forward piece of data was produced and should be emitted by this enumerator</returns>
        protected override bool RequiresFillForwardData(TimeSpan fillForwardResolution, BaseData previous, BaseData next, out BaseData fillForward)
        {
            fillForward = null;
            var nextExpectedDataPointTime = (previous.EndTime + fillForwardResolution);
            if (next != null)
            {
                // if not future data, just return the 'next'
                if (next.EndTime <= nextExpectedDataPointTime)
                {
                    return false;
                }
                // next is future data, fill forward in between
                var clone = previous.Clone(true);
                clone.Time = previous.Time + fillForwardResolution;
                fillForward = clone;
                return true;
            }

            // the underlying enumerator returned null, check to see if time has passed for fill fowarding
            var currentLocalTime = _timeProvider.GetUtcNow().ConvertFromUtc(Exchange.TimeZone);
            if (nextExpectedDataPointTime <= currentLocalTime)
            {
                var clone = previous.Clone(true);
                clone.Time = previous.Time + fillForwardResolution;
                fillForward = clone;
                return true;
            }

            return false;
        }
开发者ID:skyfyl,项目名称:Lean,代码行数:38,代码来源:LiveFillForwardEnumerator.cs

示例5: Filter

        /// <summary>
        /// Filters the input set of symbols using the underlying price data
        /// </summary>
        /// <param name="symbols">The derivative symbols to be filtered</param>
        /// <param name="underlying">The underlying price data</param>
        /// <returns>The filtered set of symbols</returns>
        public IEnumerable<Symbol> Filter(IEnumerable<Symbol> symbols, BaseData underlying)
        {
            // we can't properly apply this filter without knowing the underlying price
            // so in the event we're missing the underlying, just skip the filtering step
            if (underlying == null)
            {
                return symbols;
            }

            if (underlying.Time.Date != _strikeSizeResolveDate)
            {
                // each day we need to recompute the strike size
                symbols = symbols.ToList();
                var uniqueStrikes = symbols.DistinctBy(x => x.ID.StrikePrice).OrderBy(x => x.ID.StrikePrice).ToList();
                _strikeSize = uniqueStrikes.Zip(uniqueStrikes.Skip(1), (l, r) => r.ID.StrikePrice - l.ID.StrikePrice).DefaultIfEmpty(5m).Min();
                _strikeSizeResolveDate = underlying.Time.Date;
            }

            // compute the bounds, no need to worry about rounding and such
            var minPrice = underlying.Price + _minStrike*_strikeSize;
            var maxPrice = underlying.Price + _maxStrike*_strikeSize;
            var minExpiry = underlying.Time.Date + _minExpiry;
            var maxExpiry = underlying.Time.Date + _maxExpiry;

            // ReSharper disable once PossibleMultipleEnumeration - ReSharper is wrong here due to the ToList call
            return from symbol in symbols
                   let contract = symbol.ID
                   where contract.StrikePrice >= minPrice
                      && contract.StrikePrice <= maxPrice
                      && contract.Date >= minExpiry
                      && contract.Date <= maxExpiry
                   select symbol;
        }
开发者ID:AlexCatarino,项目名称:Lean,代码行数:39,代码来源:StrikeExpiryOptionFilter.cs

示例6: Process

 /// <summary>
 /// Invoked for each piece of data from the source file
 /// </summary>
 /// <param name="data">The data to be processed</param>
 public void Process(BaseData data)
 {
     foreach (var processor in _processors)
     {
         processor.Process(data);
     }
 }
开发者ID:kaffeebrauer,项目名称:Lean,代码行数:11,代码来源:PipeDataProcessor.cs

示例7: TextSubscriptionDataSourceReader

 /// <summary>
 /// Initializes a new instance of the <see cref="TextSubscriptionDataSourceReader"/> class
 /// </summary>
 /// <param name="dataFileProvider">Attempts to fetch remote file provider</param>
 /// <param name="config">The subscription's configuration</param>
 /// <param name="date">The date this factory was produced to read data for</param>
 /// <param name="isLiveMode">True if we're in live mode, false for backtesting</param>
 public TextSubscriptionDataSourceReader(IDataFileProvider dataFileProvider, SubscriptionDataConfig config, DateTime date, bool isLiveMode)
 {
     _dataFileProvider = dataFileProvider;
     _date = date;
     _config = config;
     _isLiveMode = isLiveMode;
     _factory = (BaseData) ObjectActivator.GetActivator(config.Type).Invoke(new object[0]);
 }
开发者ID:AlexCatarino,项目名称:Lean,代码行数:15,代码来源:TextSubscriptionDataSourceReader.cs

示例8: ZipEntryNameSubscriptionDataSourceReader

 /// <summary>
 /// Initializes a new instance of the <see cref="ZipEntryNameSubscriptionDataSourceReader"/> class
 /// </summary>
 /// <param name="dataFileProvider">Attempts to fetch remote file</param>
 /// <param name="config">The subscription's configuration</param>
 /// <param name="date">The date this factory was produced to read data for</param>
 /// <param name="isLiveMode">True if we're in live mode, false for backtesting</param>
 public ZipEntryNameSubscriptionDataSourceReader(IDataFileProvider dataFileProvider, SubscriptionDataConfig config, DateTime date, bool isLiveMode)
 {
     _dataFileProvider = dataFileProvider;
     _config = config;
     _date = date;
     _isLiveMode = isLiveMode;
     _factory = (BaseData) Activator.CreateInstance(config.Type);
 }
开发者ID:AlexCatarino,项目名称:Lean,代码行数:15,代码来源:ZipEntryNameSubscriptionDataSourceReader.cs

示例9: StreamStore

 /// <summary>
 /// Create a new self updating, thread safe data updater.
 /// </summary>
 /// <param name="config">Configuration for subscription</param>
 /// <param name="security">Security for the subscription</param>
 public StreamStore(SubscriptionDataConfig config, Security security)
 {
     _type = config.Type;
     _data = null;
     _config = config;
     _security = security;
     _increment = config.Increment;
     _queue = new ConcurrentQueue<BaseData>();
 }
开发者ID:sopnic,项目名称:Lean,代码行数:14,代码来源:StreamStore.cs

示例10: StreamStore

 /********************************************************
 * CLASS CONSTRUCTOR
 *********************************************************/
 /// <summary>
 /// Create a new self updating, thread safe data updater.
 /// </summary>
 /// <param name="config">Configuration for subscription</param>
 public StreamStore(SubscriptionDataConfig config)
 {
     _type = config.Type;
     _data = null;
     _lock = new object();
     _config = config;
     _increment = config.Increment;
     _queue = new ConcurrentQueue<BaseData>();
 }
开发者ID:intelliBrain,项目名称:Lean,代码行数:16,代码来源:StreamStore.cs

示例11: Update

 /// <summary>
 /// Updates this cash object with the specified data
 /// </summary>
 /// <param name="data">The new data for this cash object</param>
 public void Update(BaseData data)
 {
     if (_isBaseCurrency) return;
     
     var rate = data.Value;
     if (_invertRealTimePrice)
     {
         rate = 1/rate;
     }
     ConversionRate = rate;
 }
开发者ID:iorixyz,项目名称:Lean,代码行数:15,代码来源:Cash.cs

示例12: Process

        /// <summary>
        /// Invoked for each piece of data from the source file
        /// </summary>
        /// <param name="data">The data to be processed</param>
        public void Process(BaseData data)
        {
            // grab the correct consolidator for this symbol
            IDataConsolidator consolidator;
            if (!_consolidators.TryGetValue(data.Symbol, out consolidator))
            {
                consolidator = _createConsolidator(data);
                consolidator.DataConsolidated += OnDataConsolidated;
                _consolidators[data.Symbol] = consolidator;
            }

            consolidator.Update(data);
        }
开发者ID:kaffeebrauer,项目名称:Lean,代码行数:17,代码来源:ConsolidatorDataProcessor.cs

示例13: StreamStore

 /// <summary>
 /// Create a new self updating, thread safe data updater.
 /// </summary>
 /// <param name="config">Configuration for subscription</param>
 /// <param name="security">Security for the subscription</param>
 public StreamStore(SubscriptionDataConfig config, Security security)
 {
     _type = config.Type;
     _data = null;
     _config = config;
     _security = security;
     _increment = config.Increment;
     _queue = new ConcurrentQueue<BaseData>();
     if (config.Resolution == Resolution.Tick)
     {
         throw new ArgumentException("StreamStores are only for non-tick subscriptions");
     }
 }
开发者ID:Vincent-Chin,项目名称:Lean,代码行数:18,代码来源:StreamStore.cs

示例14: OnDataConsolidated

        /// <summary>
        /// Handles the <see cref="IDataConsolidator.DataConsolidated"/> event
        /// </summary>
        private void OnDataConsolidated(object sender, BaseData args)
        {
            _destination.Process(args);

            // we've already checked this frontier time, so don't scan the consolidators
            if (_frontier >= args.EndTime) return;
            _frontier = args.EndTime;

            // check the other consolidators to see if they also need to emit
            foreach (var consolidator in _consolidators.Values)
            {
                // back up the time a single instance, this allows data at exact same
                // time to still come through
                consolidator.Scan(args.EndTime.AddTicks(-1));
            }
        }
开发者ID:kaffeebrauer,项目名称:Lean,代码行数:19,代码来源:ConsolidatorDataProcessor.cs

示例15: Update

 /// <summary>
 /// Updates this model using the new price information in
 /// the specified security instance
 /// </summary>
 /// <param name="security">The security to calculate volatility for</param>
 /// <param name="data"></param>
 public void Update(Security security, BaseData data)
 {
     var timeSinceLastUpdate = data.EndTime - _lastUpdate;
     if (timeSinceLastUpdate >= _periodSpan)
     {
         lock (_sync)
         {
             _needsUpdate = true;
             // we purposefully use security.Price for consistency in our reporting
             // some streams of data will have trade/quote data, so if we just use
             // data.Value we could be mixing and matching data streams
             _window.Add((double) security.Price);
         }
         _lastUpdate = data.EndTime;
     }
 }
开发者ID:kaffeebrauer,项目名称:Lean,代码行数:22,代码来源:RelativeStandardDeviationVolatilityModel.cs


注:本文中的QuantConnect.Data.BaseData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。