當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。