public SymbolData(QCAlgorithm algorithm, Security security, int period, Resolution resolution) { Security = security; Consolidator = algorithm.ResolveConsolidator(security.Symbol, resolution); var smaName = algorithm.CreateIndicatorName(security.Symbol, "SMA" + period, resolution); SMA = new SimpleMovingAverage(smaName, period); var stdName = algorithm.CreateIndicatorName(security.Symbol, "STD" + period, resolution); STD = new StandardDeviation(stdName, period); algorithm.SubscriptionManager.AddConsolidator(security.Symbol, Consolidator); Consolidator.DataConsolidated += (sender, consolidated) => { SMA.Update(consolidated.EndTime, consolidated.Value); STD.Update(consolidated.EndTime, consolidated.Value); }; }
/// <summary> /// Initialize a new instance of <see cref="SymbolData"/> /// </summary> public SymbolData(QCAlgorithm algorithm, Security security) { Security = security; Consolidator = algorithm.ResolveConsolidator(security.Symbol, security.Resolution); var name = algorithm.CreateIndicatorName(security.Symbol, "VWAP", security.Resolution); VWAP = new IntradayVwap(name); algorithm.RegisterIndicator(security.Symbol, VWAP, Consolidator, bd => (BaseData)bd); }
public SymbolData(QCAlgorithm algorithm, Security security, int period, Resolution resolution) { Security = security; Consolidator = algorithm.ResolveConsolidator(security.Symbol, resolution); var smaName = algorithm.CreateIndicatorName(security.Symbol, "SMA" + period, resolution); SMA = new SimpleMovingAverage(smaName, period); algorithm.RegisterIndicator(security.Symbol, SMA, Consolidator); var stdName = algorithm.CreateIndicatorName(security.Symbol, "STD" + period, resolution); STD = new StandardDeviation(stdName, period); algorithm.RegisterIndicator(security.Symbol, STD, Consolidator); // warmup our indicators by pushing history through the indicators foreach (var bar in algorithm.History(Security.Symbol, period, resolution)) { SMA.Update(bar.EndTime, bar.Value); STD.Update(bar.EndTime, bar.Value); } }
public void CreateIndicatorName(Symbol symbol, string baseName, Resolution resolution, string expectation) { Assert.AreEqual(expectation, _algorithm.CreateIndicatorName(symbol, baseName, resolution)); }