17 using System.Collections.Generic;
29 private DateTime _nextRefreshTimeUtc;
31 private readonly TimeSpan _refreshInterval;
33 private readonly Func<DateTime, IEnumerable<Symbol>> _optionChainSymbolSelector;
46 : this(refreshInterval, optionChainSymbolSelector, null)
57 TimeSpan refreshInterval,
58 Func<DateTime, IEnumerable<Symbol>> optionChainSymbolSelector,
62 _nextRefreshTimeUtc = DateTime.MinValue;
64 _refreshInterval = refreshInterval;
65 _universeSettings = universeSettings;
66 _optionChainSymbolSelector = optionChainSymbolSelector;
76 _nextRefreshTimeUtc = algorithm.
UtcTime + _refreshInterval;
78 var uniqueUnderlyingSymbols =
new HashSet<Symbol>();
79 foreach (var optionSymbol
in _optionChainSymbolSelector(algorithm.UtcTime))
81 if (!optionSymbol.SecurityType.IsOption())
83 throw new ArgumentException(
"optionChainSymbolSelector must return option, index options, or futures options symbols.");
87 if (uniqueUnderlyingSymbols.Add(optionSymbol.Underlying))
89 yield
return algorithm.CreateOptionChain(optionSymbol,
Filter, _universeSettings);