本文整理汇总了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);
}
示例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]);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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]);
}
示例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);
}
示例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>();
}
示例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>();
}
示例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;
}
示例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);
}
示例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");
}
}
示例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));
}
}
示例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;
}
}