/// <summary> /// Creates the universes for this algorithm. Called once after <see cref="IAlgorithm.Initialize"/> /// </summary> /// <param name="algorithm">The algorithm instance to create universes for</param> /// <returns>The universes to be used by the algorithm</returns> public override IEnumerable <Universe> CreateUniverses(QCAlgorithm algorithm) { _nextRefreshTimeUtc = DateTime.MaxValue; foreach (var optionSymbol in _currentSymbols) { yield return(algorithm.CreateOptionChain(optionSymbol, _optionFilter, _universeSettings)); } }
/// <summary> /// Creates the universes for this algorithm. Called once after <see cref="IAlgorithm.Initialize"/> /// </summary> /// <param name="algorithm">The algorithm instance to create universes for</param> /// <returns>The universes to be used by the algorithm</returns> public override IEnumerable <Universe> CreateUniverses(QCAlgorithm algorithm) { _nextRefreshTimeUtc = algorithm.UtcTime + _refreshInterval; var uniqueUnderlyingSymbols = new HashSet <Symbol>(); foreach (var optionSymbol in _optionChainSymbolSelector(algorithm.UtcTime)) { if (optionSymbol.SecurityType != SecurityType.Option) { throw new ArgumentException("optionChainSymbolSelector must return option symbols."); } // prevent creating duplicate option chains -- one per underlying if (uniqueUnderlyingSymbols.Add(optionSymbol.Underlying)) { yield return(algorithm.CreateOptionChain(optionSymbol, Filter, _universeSettings)); } } }