17 using System.Collections.Generic;
34 private readonly
int _period;
35 private readonly decimal _deviations;
38 private readonly Dictionary<Symbol, SymbolData> _symbolData;
55 decimal deviations = 2m,
60 _deviations = deviations;
61 _resolution = resolution;
63 _symbolData =
new Dictionary<Symbol, SymbolData>();
74 _targetsCollection.AddRange(targets);
77 if (!_targetsCollection.IsEmpty)
79 foreach (var target
in _targetsCollection.OrderByMarginImpact(algorithm))
81 var symbol = target.Symbol;
88 if (!_symbolData.TryGetValue(symbol, out data))
106 _targetsCollection.ClearFulfilled(algorithm);
117 foreach (var added
in changes.AddedSecurities)
120 if (!_symbolData.ContainsKey(added.Symbol))
122 _symbolData[added.Symbol] =
new SymbolData(algorithm, added, _period, _resolution);
126 foreach (var removed
in changes.RemovedSecurities)
130 if (_symbolData.TryGetValue(removed.Symbol, out data))
134 _symbolData.Remove(removed.Symbol);
135 algorithm.SubscriptionManager.RemoveConsolidator(removed.Symbol, data.Consolidator);
147 var deviations = _deviations * data.
STD;
148 return unorderedQuantity > 0
159 return !algorithm.
UniverseManager.Any(kvp => kvp.Value.ContainsMember(symbol));
208 foreach (var bar
in algorithm.History(
Security.
Symbol, period, resolution))
210 SMA.Update(bar.EndTime, bar.Value);
211 STD.Update(bar.EndTime, bar.Value);