/// <summary> /// Event fired each time the we add/remove securities from the data feed /// </summary> /// <param name="algorithm">The algorithm instance that experienced the change in securities</param> /// <param name="changes">The security additions and removals from the algorithm</param> public override void OnSecuritiesChanged(QCAlgorithmFramework algorithm, SecurityChanges changes) { // save securities removed so we can zero out our holdings _removedSymbols = changes.RemovedSecurities.Select(x => x.Symbol).ToList(); // remove the insights of the removed symbol from the collection foreach (var removedSymbol in _removedSymbols) { List <Insight> insights; if (_insightCollection.TryGetValue(removedSymbol, out insights)) { foreach (var insight in insights.ToList()) { _insightCollection.Remove(insight); } } } }