diff --git a/Algorithm.CSharp/CapmAlphaRankingFrameworkAlgorithm.cs b/Algorithm.CSharp/CapmAlphaRankingFrameworkAlgorithm.cs index 8de949c8213a..246e61f3a746 100644 --- a/Algorithm.CSharp/CapmAlphaRankingFrameworkAlgorithm.cs +++ b/Algorithm.CSharp/CapmAlphaRankingFrameworkAlgorithm.cs @@ -81,8 +81,7 @@ public override IEnumerable CreateUniverses(QCAlgorithm algorithm) algorithm.DateRules.MonthStart(benchmark.Symbol), algorithm.TimeRules.AfterMarketOpen(benchmark.Symbol), datetime => SelectPair(algorithm, datetime), - algorithm.UniverseSettings, - algorithm.SecurityInitializer); + algorithm.UniverseSettings); } /// diff --git a/Algorithm.CSharp/CoarseTiingoNewsUniverseSelectionAlgorithm.cs b/Algorithm.CSharp/CoarseTiingoNewsUniverseSelectionAlgorithm.cs index f035d0c62adc..2233f5322d33 100644 --- a/Algorithm.CSharp/CoarseTiingoNewsUniverseSelectionAlgorithm.cs +++ b/Algorithm.CSharp/CoarseTiingoNewsUniverseSelectionAlgorithm.cs @@ -40,7 +40,7 @@ public override void Initialize() UniverseSettings.FillForward = false; - AddUniverse(new CustomDataCoarseFundamentalUniverse(UniverseSettings, SecurityInitializer, CoarseSelectionFunction)); + AddUniverse(new CustomDataCoarseFundamentalUniverse(UniverseSettings, CoarseSelectionFunction)); _symbols = new List(); } @@ -93,8 +93,8 @@ public override void OnSecuritiesChanged(SecurityChanges changes) private class CustomDataCoarseFundamentalUniverse : CoarseFundamentalUniverse { - public CustomDataCoarseFundamentalUniverse(UniverseSettings universeSettings, ISecurityInitializer securityInitializer, Func, IEnumerable> selector) - : base(universeSettings, securityInitializer, selector) + public CustomDataCoarseFundamentalUniverse(UniverseSettings universeSettings, Func, IEnumerable> selector) + : base(universeSettings, selector) { } public override IEnumerable GetSubscriptionRequests(Security security, DateTime currentTimeUtc, DateTime maximumEndTimeUtc, diff --git a/Algorithm.Framework/Selection/CoarseFundamentalUniverseSelectionModel.cs b/Algorithm.Framework/Selection/CoarseFundamentalUniverseSelectionModel.cs index 6d4322dcc0c0..d0092b9625a5 100644 --- a/Algorithm.Framework/Selection/CoarseFundamentalUniverseSelectionModel.cs +++ b/Algorithm.Framework/Selection/CoarseFundamentalUniverseSelectionModel.cs @@ -32,13 +32,11 @@ public class CoarseFundamentalUniverseSelectionModel : FundamentalUniverseSelect /// /// Selects symbols from the provided coarse data set /// Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - /// Performs extra initialization (such as setting models) after we create a new security object public CoarseFundamentalUniverseSelectionModel( Func, IEnumerable> coarseSelector, - UniverseSettings universeSettings = null, - ISecurityInitializer securityInitializer = null + UniverseSettings universeSettings = null ) - : base(false, universeSettings, securityInitializer) + : base(false, universeSettings) { _coarseSelector = coarseSelector; } @@ -48,13 +46,11 @@ public CoarseFundamentalUniverseSelectionModel( /// /// Selects symbols from the provided coarse data set /// Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - /// Performs extra initialization (such as setting models) after we create a new security object public CoarseFundamentalUniverseSelectionModel( PyObject coarseSelector, - UniverseSettings universeSettings = null, - ISecurityInitializer securityInitializer = null + UniverseSettings universeSettings = null ) - : base(false, universeSettings, securityInitializer) + : base(false, universeSettings) { Func, object> func; if (coarseSelector.TryConvertToDelegate(out func)) diff --git a/Algorithm.Framework/Selection/EmaCrossUniverseSelectionModel.cs b/Algorithm.Framework/Selection/EmaCrossUniverseSelectionModel.cs index 654ee7e0d64f..774797f14379 100644 --- a/Algorithm.Framework/Selection/EmaCrossUniverseSelectionModel.cs +++ b/Algorithm.Framework/Selection/EmaCrossUniverseSelectionModel.cs @@ -43,15 +43,13 @@ public class EmaCrossUniverseSelectionModel : FundamentalUniverseSelectionModel /// Fast EMA period /// Slow EMA period /// Maximum number of members of this universe selection - /// The settings used when adding symbols to the algorithm, specify null to use algorthm.UniverseSettings - /// Optional security initializer invoked when creating new securities, specify null to use algorithm.SecurityInitializer + /// The settings used when adding symbols to the algorithm, specify null to use algorithm.UniverseSettings public EmaCrossUniverseSelectionModel( int fastPeriod = 100, int slowPeriod = 300, int universeCount = 500, - UniverseSettings universeSettings = null, - ISecurityInitializer securityInitializer = null) - : base(false, universeSettings, securityInitializer) + UniverseSettings universeSettings = null) + : base(false, universeSettings) { _fastPeriod = fastPeriod; _slowPeriod = slowPeriod; diff --git a/Algorithm.Framework/Selection/EmaCrossUniverseSelectionModel.py b/Algorithm.Framework/Selection/EmaCrossUniverseSelectionModel.py index 8211e8195e7c..084915f46590 100644 --- a/Algorithm.Framework/Selection/EmaCrossUniverseSelectionModel.py +++ b/Algorithm.Framework/Selection/EmaCrossUniverseSelectionModel.py @@ -29,16 +29,14 @@ def __init__(self, fastPeriod = 100, slowPeriod = 300, universeCount = 500, - universeSettings = None, - securityInitializer = None): + universeSettings = None): '''Initializes a new instance of the EmaCrossUniverseSelectionModel class Args: fastPeriod: Fast EMA period slowPeriod: Slow EMA period universeCount: Maximum number of members of this universe selection - universeSettings: The settings used when adding symbols to the algorithm, specify null to use algorthm.UniverseSettings - securityInitializer: Optional security initializer invoked when creating new securities, specify null to use algorithm.SecurityInitializer''' - super().__init__(False, universeSettings, securityInitializer) + universeSettings: The settings used when adding symbols to the algorithm, specify null to use algorthm.UniverseSettings''' + super().__init__(False, universeSettings) self.fastPeriod = fastPeriod self.slowPeriod = slowPeriod self.universeCount = universeCount diff --git a/Algorithm.Framework/Selection/FineFundamentalUniverseSelectionModel.cs b/Algorithm.Framework/Selection/FineFundamentalUniverseSelectionModel.cs index 778bc2e7eba8..f011804ed778 100644 --- a/Algorithm.Framework/Selection/FineFundamentalUniverseSelectionModel.cs +++ b/Algorithm.Framework/Selection/FineFundamentalUniverseSelectionModel.cs @@ -36,14 +36,11 @@ public class FineFundamentalUniverseSelectionModel : FundamentalUniverseSelectio /// Selects symbols from the provided coarse data set /// Selects symbols from the provided fine data set (this set has already been filtered according to the coarse selection) /// Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - /// Performs extra initialization (such as setting models) after we create a new security object public FineFundamentalUniverseSelectionModel( Func, IEnumerable> coarseSelector, Func, IEnumerable> fineSelector, - UniverseSettings universeSettings = null, - ISecurityInitializer securityInitializer = null - ) - : base(true, universeSettings, securityInitializer) + UniverseSettings universeSettings = null) + : base(true, universeSettings) { _coarseSelector = coarseSelector; _fineSelector = fineSelector; @@ -55,14 +52,12 @@ public FineFundamentalUniverseSelectionModel( /// Selects symbols from the provided coarse data set /// Selects symbols from the provided fine data set (this set has already been filtered according to the coarse selection) /// Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - /// Performs extra initialization (such as setting models) after we create a new security object public FineFundamentalUniverseSelectionModel( PyObject coarseSelector, PyObject fineSelector, - UniverseSettings universeSettings = null, - ISecurityInitializer securityInitializer = null + UniverseSettings universeSettings = null ) - : base(true, universeSettings, securityInitializer) + : base(true, universeSettings) { Func, object> fineFunc; Func, object> coarseFunc; diff --git a/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.cs b/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.cs index e54db7b411cb..0ae767c58087 100644 --- a/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.cs +++ b/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.cs @@ -29,14 +29,13 @@ public abstract class FundamentalUniverseSelectionModel : UniverseSelectionModel { private readonly bool _filterFineData; private readonly UniverseSettings _universeSettings; - private readonly ISecurityInitializer _securityInitializer; /// /// Initializes a new instance of the class /// /// True to also filter using fine fundamental data, false to only filter on coarse data protected FundamentalUniverseSelectionModel(bool filterFineData) - : this(filterFineData, null, null) + : this(filterFineData, null) { } @@ -44,13 +43,11 @@ protected FundamentalUniverseSelectionModel(bool filterFineData) /// Initializes a new instance of the class /// /// True to also filter using fine fundamental data, false to only filter on coarse data - /// The settings used when adding symbols to the algorithm, specify null to use algorthm.UniverseSettings - /// Optional security initializer invoked when creating new securities, specify null to use algorithm.SecurityInitializer - protected FundamentalUniverseSelectionModel(bool filterFineData, UniverseSettings universeSettings, ISecurityInitializer securityInitializer) + /// The settings used when adding symbols to the algorithm, specify null to use algorithm.UniverseSettings + protected FundamentalUniverseSelectionModel(bool filterFineData, UniverseSettings universeSettings) { _filterFineData = filterFineData; _universeSettings = universeSettings; - _securityInitializer = securityInitializer; } /// @@ -77,8 +74,7 @@ public override IEnumerable CreateUniverses(QCAlgorithm algorithm) public virtual Universe CreateCoarseFundamentalUniverse(QCAlgorithm algorithm) { var universeSettings = _universeSettings ?? algorithm.UniverseSettings; - var securityInitializer = _securityInitializer ?? algorithm.SecurityInitializer; - return new CoarseFundamentalUniverse(universeSettings, securityInitializer, coarse => + return new CoarseFundamentalUniverse(universeSettings, coarse => { // if we're using fine fundamental selection than exclude symbols without fine data if (_filterFineData) diff --git a/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.py b/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.py index 5cbe22f9adb8..c25ef6214bbc 100644 --- a/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.py +++ b/Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.py @@ -23,16 +23,13 @@ class FundamentalUniverseSelectionModel: def __init__(self, filterFineData, - universeSettings = None, - securityInitializer = None): + universeSettings = None): '''Initializes a new instance of the FundamentalUniverseSelectionModel class Args: filterFineData: True to also filter using fine fundamental data, false to only filter on coarse data - universeSettings: The settings used when adding symbols to the algorithm, specify null to use algorthm.UniverseSettings - securityInitializer: Optional security initializer invoked when creating new securities, specify null to use algorithm.SecurityInitializer''' + universeSettings: The settings used when adding symbols to the algorithm, specify null to use algorthm.UniverseSettings''' self.filterFineData = filterFineData self.universeSettings = universeSettings - self.securityInitializer = securityInitializer def CreateUniverses(self, algorithm): @@ -55,8 +52,7 @@ def CreateCoarseFundamentalUniverse(self, algorithm): Returns: The coarse fundamental universe''' universeSettings = algorithm.UniverseSettings if self.universeSettings is None else self.universeSettings - securityInitializer = algorithm.SecurityInitializer if self.securityInitializer is None else self.securityInitializer - return CoarseFundamentalUniverse(universeSettings, securityInitializer, lambda coarse: self.FilteredSelectCoarse(algorithm, coarse)) + return CoarseFundamentalUniverse(universeSettings, lambda coarse: self.FilteredSelectCoarse(algorithm, coarse)) def FilteredSelectCoarse(self, algorithm, coarse): diff --git a/Algorithm.Framework/Selection/FutureUniverseSelectionModel.cs b/Algorithm.Framework/Selection/FutureUniverseSelectionModel.cs index c1cc699a2063..09f6eb813aa0 100644 --- a/Algorithm.Framework/Selection/FutureUniverseSelectionModel.cs +++ b/Algorithm.Framework/Selection/FutureUniverseSelectionModel.cs @@ -50,25 +50,6 @@ public FutureUniverseSelectionModel(TimeSpan refreshInterval, Func - /// Creates a new instance of - /// - /// Time interval between universe refreshes - /// Selects symbols from the provided future chain - /// Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - /// Performs extra initialization (such as setting models) after we create a new security object - [Obsolete("This constructor is obsolete because SecurityInitializer is obsolete and will not be used.")] - public FutureUniverseSelectionModel( - TimeSpan refreshInterval, - Func> futureChainSymbolSelector, - UniverseSettings universeSettings, - ISecurityInitializer securityInitializer - ) - : this(refreshInterval, futureChainSymbolSelector, universeSettings) - { - - } - /// /// Creates a new instance of /// @@ -113,24 +94,6 @@ public override IEnumerable CreateUniverses(QCAlgorithm algorithm) } } - /// - /// Creates the canonical chain security for a given symbol - /// - /// The algorithm instance to create universes for - /// Symbol of the future - /// Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - /// Performs extra initialization (such as setting models) after we create a new security object - /// for the given symbol - [Obsolete("This method is obsolete because SecurityInitializer is obsolete and will not be used.")] - protected virtual Future CreateFutureChainSecurity(QCAlgorithm algorithm, Symbol symbol, UniverseSettings settings, ISecurityInitializer initializer) - { - return CreateFutureChainSecurity( - algorithm.SubscriptionManager.SubscriptionDataConfigService, - symbol, - settings, - algorithm.Securities); - } - /// /// Creates the canonical chain security for a given symbol /// diff --git a/Algorithm.Framework/Selection/FutureUniverseSelectionModel.py b/Algorithm.Framework/Selection/FutureUniverseSelectionModel.py index 1721f2485399..78bc26ec7fd8 100644 --- a/Algorithm.Framework/Selection/FutureUniverseSelectionModel.py +++ b/Algorithm.Framework/Selection/FutureUniverseSelectionModel.py @@ -29,20 +29,17 @@ class FutureUniverseSelectionModel(UniverseSelectionModel): def __init__(self, refreshInterval, futureChainSymbolSelector, - universeSettings = None, - securityInitializer = None): + universeSettings = None): '''Creates a new instance of FutureUniverseSelectionModel Args: refreshInterval: Time interval between universe refreshes futureChainSymbolSelector: Selects symbols from the provided future chain - universeSettings: Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - securityInitializer: [Obsolete, will not be used] Performs extra initialization (such as setting models) after we create a new security object''' + universeSettings: Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed''' self.nextRefreshTimeUtc = datetime.min self.refreshInterval = refreshInterval self.futureChainSymbolSelector = futureChainSymbolSelector self.universeSettings = universeSettings - self.securityInitializer = securityInitializer def GetNextRefreshTimeUtc(self): '''Gets the next time the framework should invoke the `CreateUniverses` method to refresh the set of universes.''' @@ -83,11 +80,10 @@ def CreateFutureChain(self, algorithm, symbol): # resolve defaults if not specified settings = self.universeSettings if self.universeSettings is not None else algorithm.UniverseSettings - initializer = self.securityInitializer if self.securityInitializer is not None else algorithm.SecurityInitializer # create canonical security object, but don't duplicate if it already exists securities = [s for s in algorithm.Securities if s.Key == symbol] if len(securities) == 0: - futureChain = self.CreateFutureChainSecurity(algorithm, symbol, settings, initializer) + futureChain = self.CreateFutureChainSecurity(algorithm, symbol, settings) else: futureChain = securities[0] @@ -97,15 +93,14 @@ def CreateFutureChain(self, algorithm, symbol): # force future chain security to not be directly tradable AFTER it's configured to ensure it's not overwritten futureChain.IsTradable = False - return FuturesChainUniverse(futureChain, settings, algorithm.SubscriptionManager, initializer) + return FuturesChainUniverse(futureChain, settings) - def CreateFutureChainSecurity(self, algorithm, symbol, settings, initializer): + def CreateFutureChainSecurity(self, algorithm, symbol, settings): '''Creates the canonical Future chain security for a given symbol Args: algorithm: The algorithm instance to create universes for symbol: Symbol of the future settings: Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - initializer: [Obsolete, will not be used] Performs extra initialization (such as setting models) after we create a new security object Returns Future for the given symbol''' config = algorithm.SubscriptionManager.SubscriptionDataConfigService.Add(typeof(ZipEntryName), diff --git a/Algorithm.Framework/Selection/OptionUniverseSelectionModel.cs b/Algorithm.Framework/Selection/OptionUniverseSelectionModel.cs index fa1b4d41fa28..d5fb724bfa8b 100644 --- a/Algorithm.Framework/Selection/OptionUniverseSelectionModel.cs +++ b/Algorithm.Framework/Selection/OptionUniverseSelectionModel.cs @@ -47,24 +47,6 @@ public OptionUniverseSelectionModel(TimeSpan refreshInterval, Func - /// Creates a new instance of - /// - /// Time interval between universe refreshes - /// Selects symbols from the provided option chain - /// Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - /// Performs extra initialization (such as setting models) after we create a new security object - [Obsolete("This constructor is obsolete because SecurityInitializer is obsolete and will not be used.")] - public OptionUniverseSelectionModel( - TimeSpan refreshInterval, - Func> optionChainSymbolSelector, - UniverseSettings universeSettings, - ISecurityInitializer securityInitializer - ) - :this (refreshInterval,optionChainSymbolSelector,universeSettings) - { - } - /// /// Creates a new instance of /// diff --git a/Algorithm.Framework/Selection/OptionUniverseSelectionModel.py b/Algorithm.Framework/Selection/OptionUniverseSelectionModel.py index 40e7a41c3311..89b0d39c8505 100644 --- a/Algorithm.Framework/Selection/OptionUniverseSelectionModel.py +++ b/Algorithm.Framework/Selection/OptionUniverseSelectionModel.py @@ -29,20 +29,17 @@ class OptionUniverseSelectionModel(UniverseSelectionModel): def __init__(self, refreshInterval, optionChainSymbolSelector, - universeSettings = None, - securityInitializer = None): + universeSettings = None): '''Creates a new instance of OptionUniverseSelectionModel Args: refreshInterval: Time interval between universe refreshes optionChainSymbolSelector: Selects symbols from the provided option chain - universeSettings: Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - securityInitializer: [Obsolete, will not be used] Performs extra initialization (such as setting models) after we create a new security object''' + universeSettings: Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed''' self.nextRefreshTimeUtc = datetime.min self.refreshInterval = refreshInterval self.optionChainSymbolSelector = optionChainSymbolSelector self.universeSettings = universeSettings - self.securityInitializer = securityInitializer def GetNextRefreshTimeUtc(self): '''Gets the next time the framework should invoke the `CreateUniverses` method to refresh the set of universes.''' @@ -85,11 +82,10 @@ def CreateOptionChain(self, algorithm, symbol): # resolve defaults if not specified settings = self.universeSettings if self.universeSettings is not None else algorithm.UniverseSettings - initializer = self.securityInitializer if self.securityInitializer is not None else algorithm.SecurityInitializer # create canonical security object, but don't duplicate if it already exists securities = [s for s in algorithm.Securities if s.Key == symbol] if len(securities) == 0: - optionChain = self.CreateOptionChainSecurity(algorithm, symbol, settings, initializer) + optionChain = self.CreateOptionChainSecurity(algorithm, symbol, settings) else: optionChain = securities[0] @@ -99,15 +95,14 @@ def CreateOptionChain(self, algorithm, symbol): # force option chain security to not be directly tradable AFTER it's configured to ensure it's not overwritten optionChain.IsTradable = False - return OptionChainUniverse(optionChain, settings, initializer, algorithm.LiveMode) + return OptionChainUniverse(optionChain, settings, algorithm.LiveMode) - def CreateOptionChainSecurity(self, algorithm, symbol, settings, initializer): + def CreateOptionChainSecurity(self, algorithm, symbol, settings): '''Creates the canonical option chain security for a given symbol Args: algorithm: The algorithm instance to create universes for symbol: Symbol of the option settings: Universe settings define attributes of created subscriptions, such as their resolution and the minimum time in universe before they can be removed - initializer: [Obsolete, will not be used] Performs extra initialization (such as setting models) after we create a new security object Returns Option for the given symbol''' config = algorithm.SubscriptionManager.SubscriptionDataConfigService.Add(typeof(ZipEntryName), diff --git a/Algorithm.Framework/Selection/QC500UniverseSelectionModel.cs b/Algorithm.Framework/Selection/QC500UniverseSelectionModel.cs index e586272ceca0..fc2f09b8c6f9 100644 --- a/Algorithm.Framework/Selection/QC500UniverseSelectionModel.cs +++ b/Algorithm.Framework/Selection/QC500UniverseSelectionModel.cs @@ -47,9 +47,8 @@ public QC500UniverseSelectionModel() /// Initializes a new instance of the /// /// Universe settings defines what subscription properties will be applied to selected securities - /// Security initializer initializes newly selected securities - public QC500UniverseSelectionModel(UniverseSettings universeSettings, ISecurityInitializer securityInitializer) - : base(true, universeSettings, securityInitializer) + public QC500UniverseSelectionModel(UniverseSettings universeSettings) + : base(true, universeSettings) { } diff --git a/Algorithm.Framework/Selection/QC500UniverseSelectionModel.py b/Algorithm.Framework/Selection/QC500UniverseSelectionModel.py index ddc07d68de95..10cdc6313152 100644 --- a/Algorithm.Framework/Selection/QC500UniverseSelectionModel.py +++ b/Algorithm.Framework/Selection/QC500UniverseSelectionModel.py @@ -25,9 +25,9 @@ class QC500UniverseSelectionModel(FundamentalUniverseSelectionModel): '''Defines the QC500 universe as a universe selection model for framework algorithm For details: https://github.com/QuantConnect/Lean/pull/1663''' - def __init__(self, filterFineData = True, universeSettings = None, securityInitializer = None): + def __init__(self, filterFineData = True, universeSettings = None): '''Initializes a new default instance of the QC500UniverseSelectionModel''' - super().__init__(filterFineData, universeSettings, securityInitializer) + super().__init__(filterFineData, universeSettings) self.numberOfSymbolsCoarse = 1000 self.numberOfSymbolsFine = 500 self.dollarVolumeBySymbol = {} diff --git a/Algorithm.Framework/Selection/ScheduledUniverseSelectionModel.cs b/Algorithm.Framework/Selection/ScheduledUniverseSelectionModel.cs index 770d4ea574b6..18d7dfffdada 100644 --- a/Algorithm.Framework/Selection/ScheduledUniverseSelectionModel.cs +++ b/Algorithm.Framework/Selection/ScheduledUniverseSelectionModel.cs @@ -34,7 +34,6 @@ public class ScheduledUniverseSelectionModel : UniverseSelectionModel private readonly Func> _selector; private readonly DateTimeZone _timeZone; private readonly UniverseSettings _settings; - private readonly ISecurityInitializer _initializer; /// /// Initializes a new instance of the class using the algorithm's time zone @@ -43,14 +42,12 @@ public class ScheduledUniverseSelectionModel : UniverseSelectionModel /// Time rule defines what times on each day selected by date rule the universe selection function will be invoked /// Selector function accepting the date time firing time and returning the universe selected symbols /// Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings - /// Security initializer for new securities created via this universe, null will default to algorithm's security initializer - public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, Func> selector, UniverseSettings settings = null, ISecurityInitializer initializer = null) + public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, Func> selector, UniverseSettings settings = null) { _dateRule = dateRule; _timeRule = timeRule; _selector = selector; _settings = settings; - _initializer = initializer; } /// @@ -61,15 +58,13 @@ public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, F /// Time rule defines what times on each day selected by date rule the universe selection function will be invoked /// Selector function accepting the date time firing time and returning the universe selected symbols /// Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings - /// Security initializer for new securities created via this universe, null will default to algorithm's security initializer - public ScheduledUniverseSelectionModel(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, Func> selector, UniverseSettings settings = null, ISecurityInitializer initializer = null) + public ScheduledUniverseSelectionModel(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, Func> selector, UniverseSettings settings = null) { _timeZone = timeZone; _dateRule = dateRule; _timeRule = timeRule; _selector = selector; _settings = settings; - _initializer = initializer; } /// @@ -79,9 +74,8 @@ public ScheduledUniverseSelectionModel(DateTimeZone timeZone, IDateRule dateRule /// Time rule defines what times on each day selected by date rule the universe selection function will be invoked /// Selector function accepting the date time firing time and returning the universe selected symbols /// Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings - /// Security initializer for new securities created via this universe, null will default to algorithm's security initializer - public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null, ISecurityInitializer initializer = null) - : this(null, dateRule, timeRule, selector, settings, initializer) + public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null) + : this(null, dateRule, timeRule, selector, settings) { } @@ -93,8 +87,7 @@ public ScheduledUniverseSelectionModel(IDateRule dateRule, ITimeRule timeRule, P /// Time rule defines what times on each day selected by date rule the universe selection function will be invoked /// Selector function accepting the date time firing time and returning the universe selected symbols /// Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings - /// Security initializer for new securities created via this universe, null will default to algorithm's security initializer - public ScheduledUniverseSelectionModel(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null, ISecurityInitializer initializer = null) + public ScheduledUniverseSelectionModel(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null) { Func func; selector.TryConvertToDelegate(out func); @@ -103,7 +96,6 @@ public ScheduledUniverseSelectionModel(DateTimeZone timeZone, IDateRule dateRule _timeRule = timeRule; _selector = func.ConvertToUniverseSelectionSymbolDelegate(); _settings = settings; - _initializer = initializer; } /// @@ -119,8 +111,7 @@ public override IEnumerable CreateUniverses(QCAlgorithm algorithm) _dateRule, _timeRule, _selector, - _settings ?? algorithm.UniverseSettings, - _initializer ?? algorithm.SecurityInitializer + _settings ?? algorithm.UniverseSettings ); } } diff --git a/Algorithm.Python/CoarseTiingoNewsUniverseSelectionAlgorithm.py b/Algorithm.Python/CoarseTiingoNewsUniverseSelectionAlgorithm.py index c070c05be240..81217407ab81 100644 --- a/Algorithm.Python/CoarseTiingoNewsUniverseSelectionAlgorithm.py +++ b/Algorithm.Python/CoarseTiingoNewsUniverseSelectionAlgorithm.py @@ -38,7 +38,7 @@ def Initialize(self): self.__numberOfSymbols = 3 - self.AddUniverse(CustomDataCoarseFundamentalUniverse(self.UniverseSettings, self.SecurityInitializer, self.CoarseSelectionFunction)); + self.AddUniverse(CustomDataCoarseFundamentalUniverse(self.UniverseSettings, self.CoarseSelectionFunction)); self._symbols = [] diff --git a/Algorithm/DollarVolumeUniverseDefinitions.cs b/Algorithm/DollarVolumeUniverseDefinitions.cs index c7f28ebb7fb9..29f1c623b63a 100644 --- a/Algorithm/DollarVolumeUniverseDefinitions.cs +++ b/Algorithm/DollarVolumeUniverseDefinitions.cs @@ -51,7 +51,7 @@ public Universe Top(int count, UniverseSettings universeSettings = null) universeSettings = universeSettings ?? _algorithm.UniverseSettings; var symbol = Symbol.Create("us-equity-dollar-volume-top-" + count, SecurityType.Equity, Market.USA); var config = new SubscriptionDataConfig(typeof(CoarseFundamental), symbol, Resolution.Daily, TimeZones.NewYork, TimeZones.NewYork, false, false, true); - return new FuncUniverse(config, universeSettings, _algorithm.SecurityInitializer, selectionData => ( + return new FuncUniverse(config, universeSettings, selectionData => ( from c in selectionData.OfType() orderby c.DollarVolume descending select c.Symbol).Take(count) @@ -71,7 +71,7 @@ public Universe Bottom(int count, UniverseSettings universeSettings = null) universeSettings = universeSettings ?? _algorithm.UniverseSettings; var symbol = Symbol.Create("us-equity-dollar-volume-bottom-" + count, SecurityType.Equity, Market.USA); var config = new SubscriptionDataConfig(typeof(CoarseFundamental), symbol, Resolution.Daily, TimeZones.NewYork, TimeZones.NewYork, false, false, true); - return new FuncUniverse(config, universeSettings, _algorithm.SecurityInitializer, selectionData => ( + return new FuncUniverse(config, universeSettings, selectionData => ( from c in selectionData.OfType() orderby c.DollarVolume descending select c.Symbol).Take(count) @@ -91,7 +91,7 @@ public Universe Percentile(double percentile, UniverseSettings universeSettings universeSettings = universeSettings ?? _algorithm.UniverseSettings; var symbol = Symbol.Create("us-equity-dollar-volume-percentile-" + percentile, SecurityType.Equity, Market.USA); var config = new SubscriptionDataConfig(typeof(CoarseFundamental), symbol, Resolution.Daily, TimeZones.NewYork, TimeZones.NewYork, false, false, true); - return new FuncUniverse(config, universeSettings, _algorithm.SecurityInitializer, selectionData => + return new FuncUniverse(config, universeSettings, selectionData => { var list = selectionData as IReadOnlyList ?? selectionData.OfType().ToList(); @@ -120,7 +120,7 @@ public Universe Percentile(double lowerPercentile, double upperPercentile, Unive universeSettings = universeSettings ?? _algorithm.UniverseSettings; var symbol = Symbol.Create("us-equity-dollar-volume-percentile-" + lowerPercentile + "-" + upperPercentile, SecurityType.Equity, Market.USA); var config = new SubscriptionDataConfig(typeof(CoarseFundamental), symbol, Resolution.Daily, TimeZones.NewYork, TimeZones.NewYork, false, false, true); - return new FuncUniverse(config, universeSettings, _algorithm.SecurityInitializer, selectionData => + return new FuncUniverse(config, universeSettings, selectionData => { var list = selectionData as IReadOnlyList ?? selectionData.OfType().ToList(); diff --git a/Algorithm/IndexUniverseDefinitions.cs b/Algorithm/IndexUniverseDefinitions.cs index f900f65eca13..89dc42195a9f 100644 --- a/Algorithm/IndexUniverseDefinitions.cs +++ b/Algorithm/IndexUniverseDefinitions.cs @@ -56,7 +56,6 @@ public Universe QC500 var coarseUniverse = new CoarseFundamentalUniverse( symbol, _algorithm.UniverseSettings, - _algorithm.SecurityInitializer, coarse => { if (_algorithm.Time.Month == lastMonth) diff --git a/Algorithm/QCAlgorithm.Python.cs b/Algorithm/QCAlgorithm.Python.cs index 6e23eda26c90..60cc42d9fb36 100644 --- a/Algorithm/QCAlgorithm.Python.cs +++ b/Algorithm/QCAlgorithm.Python.cs @@ -479,7 +479,7 @@ public Universe AddUniverse(Type dataType, SecurityType securityType, string nam var selector = pySelector.ConvertToDelegate, object>>(); - return AddUniverse(new FuncUniverse(config, universeSettings, SecurityInitializer, baseDatas => + return AddUniverse(new FuncUniverse(config, universeSettings, baseDatas => { var result = selector(baseDatas); return ReferenceEquals(result, Universe.Unchanged) diff --git a/Algorithm/QCAlgorithm.Universe.cs b/Algorithm/QCAlgorithm.Universe.cs index 22fb94658b72..626b0c08268c 100644 --- a/Algorithm/QCAlgorithm.Universe.cs +++ b/Algorithm/QCAlgorithm.Universe.cs @@ -364,7 +364,7 @@ public Universe AddUniverse(SecurityType securityType, string name, Resolutio var exchangeTimeZone = marketHoursDbEntry.ExchangeHours.TimeZone; var symbol = QuantConnect.Symbol.Create(name, securityType, market, baseDataType: typeof(T)); var config = new SubscriptionDataConfig(typeof(T), symbol, resolution, dataTimeZone, exchangeTimeZone, false, false, true, true, isFilteredSubscription: false); - return AddUniverse(new FuncUniverse(config, universeSettings, SecurityInitializer, d => selector(d.OfType()))); + return AddUniverse(new FuncUniverse(config, universeSettings, d => selector(d.OfType()))); } /// @@ -384,7 +384,7 @@ public Universe AddUniverse(SecurityType securityType, string name, Resolutio var exchangeTimeZone = marketHoursDbEntry.ExchangeHours.TimeZone; var symbol = QuantConnect.Symbol.Create(name, securityType, market, baseDataType: typeof(T)); var config = new SubscriptionDataConfig(typeof(T), symbol, resolution, dataTimeZone, exchangeTimeZone, false, false, true, true, isFilteredSubscription: false); - return AddUniverse(new FuncUniverse(config, universeSettings, SecurityInitializer, + return AddUniverse(new FuncUniverse(config, universeSettings, d => selector(d.OfType()).Select(x => QuantConnect.Symbol.Create(x, securityType, market, baseDataType: typeof(T)))) ); } @@ -396,7 +396,7 @@ public Universe AddUniverse(SecurityType securityType, string name, Resolutio /// Defines an initial coarse selection public Universe AddUniverse(Func, IEnumerable> selector) { - return AddUniverse(new CoarseFundamentalUniverse(UniverseSettings, SecurityInitializer, selector)); + return AddUniverse(new CoarseFundamentalUniverse(UniverseSettings, selector)); } /// @@ -407,7 +407,7 @@ public Universe AddUniverse(Func, IEnumerableDefines a more detailed selection with access to more data public Universe AddUniverse(Func, IEnumerable> coarseSelector, Func, IEnumerable> fineSelector) { - var coarse = new CoarseFundamentalUniverse(UniverseSettings, SecurityInitializer, coarseSelector); + var coarse = new CoarseFundamentalUniverse(UniverseSettings, coarseSelector); return AddUniverse(new FineFundamentalFilteredUniverse(coarse, fineSelector)); } diff --git a/Algorithm/Selection/ManualUniverse.cs b/Algorithm/Selection/ManualUniverse.cs index 1462bd2ad954..786f4f88ceae 100644 --- a/Algorithm/Selection/ManualUniverse.cs +++ b/Algorithm/Selection/ManualUniverse.cs @@ -31,18 +31,6 @@ namespace QuantConnect.Algorithm.Framework.Selection /// with different . More information public class ManualUniverse : UserDefinedUniverse { - /// - /// Creates a new instance of the - /// - [Obsolete("This constructor is obsolete because SecurityInitializer is obsolete and will not be used.")] - public ManualUniverse(SubscriptionDataConfig configuration, - UniverseSettings universeSettings, - ISecurityInitializer securityInitializer, - IEnumerable symbols) - : base(configuration, universeSettings, securityInitializer, Time.MaxTimeSpan, symbols) - { - } - /// /// Creates a new instance of the /// diff --git a/Algorithm/Selection/ManualUniverseSelectionModel.cs b/Algorithm/Selection/ManualUniverseSelectionModel.cs index dc8926f008e5..907057fdef8d 100644 --- a/Algorithm/Selection/ManualUniverseSelectionModel.cs +++ b/Algorithm/Selection/ManualUniverseSelectionModel.cs @@ -33,7 +33,6 @@ public class ManualUniverseSelectionModel : UniverseSelectionModel private readonly IReadOnlyList _symbols; private readonly UniverseSettings _universeSettings; - private readonly ISecurityInitializer _securityInitializer; /// /// Initializes a new instance of the class using the algorithm's @@ -62,7 +61,7 @@ public ManualUniverseSelectionModel(IEnumerable symbols) /// The symbols to subscribe to /// Should not send in symbols at since those will be managed by the public ManualUniverseSelectionModel(params Symbol[] symbols) - : this (symbols?.AsEnumerable(), null, null) + : this (symbols?.AsEnumerable(), null) { } @@ -72,8 +71,7 @@ public ManualUniverseSelectionModel(params Symbol[] symbols) /// The symbols to subscribe to /// Should not send in symbols at since those will be managed by the /// The settings used when adding symbols to the algorithm, specify null to use algorthm.UniverseSettings - /// Optional security initializer invoked when creating new securities, specify null to use algorithm.SecurityInitializer - public ManualUniverseSelectionModel(IEnumerable symbols, UniverseSettings universeSettings, ISecurityInitializer securityInitializer) + public ManualUniverseSelectionModel(IEnumerable symbols, UniverseSettings universeSettings) { if (symbols == null) { @@ -82,7 +80,6 @@ public ManualUniverseSelectionModel(IEnumerable symbols, UniverseSetting _symbols = symbols.Where(s => !s.IsCanonical()).ToList(); _universeSettings = universeSettings; - _securityInitializer = securityInitializer; foreach (var symbol in _symbols) { @@ -98,8 +95,6 @@ public ManualUniverseSelectionModel(IEnumerable symbols, UniverseSetting public override IEnumerable CreateUniverses(QCAlgorithm algorithm) { var universeSettings = _universeSettings ?? algorithm.UniverseSettings; - var securityInitializer = _securityInitializer ?? algorithm.SecurityInitializer; - var resolution = universeSettings.Resolution; var type = resolution == Resolution.Tick ? typeof(Tick) : typeof(TradeBar); diff --git a/Algorithm/Selection/ManualUniverseSelectionModel.py b/Algorithm/Selection/ManualUniverseSelectionModel.py index 6c9237e2924e..56654381c606 100644 --- a/Algorithm/Selection/ManualUniverseSelectionModel.py +++ b/Algorithm/Selection/ManualUniverseSelectionModel.py @@ -28,11 +28,10 @@ class ManualUniverseSelectionModel(UniverseSelectionModel): '''Provides an implementation of IUniverseSelectionModel that simply subscribes to the specified set of symbols''' - def __init__(self, symbols = list(), universeSettings = None, securityInitializer = None): + def __init__(self, symbols = list(), universeSettings = None): self.MarketHours = MarketHoursDatabase.FromDataFolder() self.symbols = symbols self.universeSettings = universeSettings - self.securityInitializer = securityInitializer for symbol in symbols: SymbolCache.Set(symbol.Value, symbol) @@ -46,9 +45,6 @@ def CreateUniverses(self, algorithm): universeSettings = self.universeSettings \ if self.universeSettings is not None else algorithm.UniverseSettings - securityInitializer = self.securityInitializer \ - if self.securityInitializer is not None else algorithm.SecurityInitializer - resolution = universeSettings.Resolution type = typeof(Tick) if resolution == Resolution.Tick else typeof(TradeBar); diff --git a/Common/Data/UniverseSelection/CoarseFundamentalUniverse.cs b/Common/Data/UniverseSelection/CoarseFundamentalUniverse.cs index 7595b7a65cc9..3df8d7c77f67 100644 --- a/Common/Data/UniverseSelection/CoarseFundamentalUniverse.cs +++ b/Common/Data/UniverseSelection/CoarseFundamentalUniverse.cs @@ -38,10 +38,9 @@ public class CoarseFundamentalUniverse : Universe /// Initializes a new instance of the class /// /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe /// Returns the symbols that should be included in the universe - public CoarseFundamentalUniverse(UniverseSettings universeSettings, ISecurityInitializer securityInitializer, Func, IEnumerable> selector) - : base(CreateConfiguration(CoarseFundamental.CreateUniverseSymbol(QuantConnect.Market.USA)), securityInitializer) + public CoarseFundamentalUniverse(UniverseSettings universeSettings, Func, IEnumerable> selector) + : base(CreateConfiguration(CoarseFundamental.CreateUniverseSymbol(QuantConnect.Market.USA))) { _universeSettings = universeSettings; _selector = selector; @@ -51,10 +50,9 @@ public CoarseFundamentalUniverse(UniverseSettings universeSettings, ISecurityIni /// Initializes a new instance of the class /// /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe /// Returns the symbols that should be included in the universe - public CoarseFundamentalUniverse(UniverseSettings universeSettings, ISecurityInitializer securityInitializer, PyObject selector) - : this(CoarseFundamental.CreateUniverseSymbol(QuantConnect.Market.USA), universeSettings, securityInitializer, selector) + public CoarseFundamentalUniverse(UniverseSettings universeSettings, PyObject selector) + : this(CoarseFundamental.CreateUniverseSymbol(QuantConnect.Market.USA), universeSettings, selector) { } @@ -63,10 +61,9 @@ public CoarseFundamentalUniverse(UniverseSettings universeSettings, ISecurityIni /// /// Defines the symbol to use for this universe /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe /// Returns the symbols that should be included in the universe - public CoarseFundamentalUniverse(Symbol symbol, UniverseSettings universeSettings, ISecurityInitializer securityInitializer, Func, IEnumerable> selector) - : base(CreateConfiguration(symbol), securityInitializer) + public CoarseFundamentalUniverse(Symbol symbol, UniverseSettings universeSettings, Func, IEnumerable> selector) + : base(CreateConfiguration(symbol)) { _universeSettings = universeSettings; _selector = selector; @@ -77,10 +74,9 @@ public CoarseFundamentalUniverse(Symbol symbol, UniverseSettings universeSetting /// /// Defines the symbol to use for this universe /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe /// Returns the symbols that should be included in the universe - public CoarseFundamentalUniverse(Symbol symbol, UniverseSettings universeSettings, ISecurityInitializer securityInitializer, PyObject selector) - : base(CreateConfiguration(symbol), securityInitializer) + public CoarseFundamentalUniverse(Symbol symbol, UniverseSettings universeSettings, PyObject selector) + : base(CreateConfiguration(symbol)) { _universeSettings = universeSettings; Func, object> func; diff --git a/Common/Data/UniverseSelection/FineFundamentalFilteredUniverse.cs b/Common/Data/UniverseSelection/FineFundamentalFilteredUniverse.cs index c05170b5e557..be8a96ebe603 100644 --- a/Common/Data/UniverseSelection/FineFundamentalFilteredUniverse.cs +++ b/Common/Data/UniverseSelection/FineFundamentalFilteredUniverse.cs @@ -39,7 +39,7 @@ public class FineFundamentalFilteredUniverse : SelectSymbolsUniverseDecorator public FineFundamentalFilteredUniverse(Universe universe, Func, IEnumerable> fineSelector) : base(universe, universe.SelectSymbols) { - FineFundamentalUniverse = new FineFundamentalUniverse(universe.UniverseSettings, universe.SecurityInitializer, fineSelector); + FineFundamentalUniverse = new FineFundamentalUniverse(universe.UniverseSettings, fineSelector); FineFundamentalUniverse.SelectionChanged += (sender, args) => OnSelectionChanged(((SelectionEventArgs) args).CurrentSelection); } @@ -52,19 +52,8 @@ public FineFundamentalFilteredUniverse(Universe universe, PyObject fineSelector) : base(universe, universe.SelectSymbols) { var func = fineSelector.ConvertToDelegate, Symbol[]>>(); - FineFundamentalUniverse = new FineFundamentalUniverse(universe.UniverseSettings, universe.SecurityInitializer, func); + FineFundamentalUniverse = new FineFundamentalUniverse(universe.UniverseSettings, func); FineFundamentalUniverse.SelectionChanged += (sender, args) => OnSelectionChanged(((SelectionEventArgs)args).CurrentSelection); } - - /// - /// Sets the security initializer, used to initialize/configure securities after creation - /// - /// The security initializer - public override void SetSecurityInitializer(ISecurityInitializer securityInitializer) - { - base.SetSecurityInitializer(securityInitializer); - Universe.SetSecurityInitializer(securityInitializer); - FineFundamentalUniverse.SetSecurityInitializer(securityInitializer); - } } } \ No newline at end of file diff --git a/Common/Data/UniverseSelection/FineFundamentalUniverse.cs b/Common/Data/UniverseSelection/FineFundamentalUniverse.cs index 9b87057a84e4..e8d9934b7fa6 100644 --- a/Common/Data/UniverseSelection/FineFundamentalUniverse.cs +++ b/Common/Data/UniverseSelection/FineFundamentalUniverse.cs @@ -41,10 +41,9 @@ public override UniverseSettings UniverseSettings /// Initializes a new instance of the class /// /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe /// Returns the symbols that should be included in the universe - public FineFundamentalUniverse(UniverseSettings universeSettings, ISecurityInitializer securityInitializer, Func, IEnumerable> selector) - : base(CreateConfiguration(FineFundamental.CreateUniverseSymbol(QuantConnect.Market.USA)), securityInitializer) + public FineFundamentalUniverse(UniverseSettings universeSettings, Func, IEnumerable> selector) + : base(CreateConfiguration(FineFundamental.CreateUniverseSymbol(QuantConnect.Market.USA))) { _universeSettings = universeSettings; _selector = selector; @@ -55,10 +54,9 @@ public FineFundamentalUniverse(UniverseSettings universeSettings, ISecurityIniti /// /// Defines the symbol to use for this universe /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe /// Returns the symbols that should be included in the universe - public FineFundamentalUniverse(Symbol symbol, UniverseSettings universeSettings, ISecurityInitializer securityInitializer, Func, IEnumerable> selector) - : base(CreateConfiguration(symbol), securityInitializer) + public FineFundamentalUniverse(Symbol symbol, UniverseSettings universeSettings, Func, IEnumerable> selector) + : base(CreateConfiguration(symbol)) { _universeSettings = universeSettings; _selector = selector; diff --git a/Common/Data/UniverseSelection/FuncUniverse.cs b/Common/Data/UniverseSelection/FuncUniverse.cs index 269baa20d3b4..5fe9547cfd9e 100644 --- a/Common/Data/UniverseSelection/FuncUniverse.cs +++ b/Common/Data/UniverseSelection/FuncUniverse.cs @@ -35,20 +35,6 @@ public override UniverseSettings UniverseSettings get { return _universeSettings; } } - /// - /// Initializes a new instance of the class - /// - /// The configuration used to resolve the data for universe selection - /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe - /// Returns the symbols that should be included in the universe - public FuncUniverse(SubscriptionDataConfig configuration, UniverseSettings universeSettings, ISecurityInitializer securityInitializer, Func, IEnumerable> universeSelector) - : base(configuration, securityInitializer) - { - _universeSelector = universeSelector; - _universeSettings = universeSettings; - } - /// /// Initializes a new instance of the class /// diff --git a/Common/Data/UniverseSelection/FuturesChainUniverse.cs b/Common/Data/UniverseSelection/FuturesChainUniverse.cs index d6a1d75fcbdc..66661528fde3 100644 --- a/Common/Data/UniverseSelection/FuturesChainUniverse.cs +++ b/Common/Data/UniverseSelection/FuturesChainUniverse.cs @@ -45,24 +45,6 @@ public FuturesChainUniverse(Future future, _universeSettings = universeSettings; } - /// - /// Initializes a new instance of the class - /// - /// The canonical future chain security - /// The universe settings to be used for new subscriptions - /// The subscription manager used to return available data types - /// The security initializer to use on newly created securities - [Obsolete("This constructor is obsolete because SecurityInitializer is obsolete and will not be used.")] - public FuturesChainUniverse(Future future, - UniverseSettings universeSettings, - SubscriptionManager subscriptionManager, - ISecurityInitializer securityInitializer = null) - : base(future.SubscriptionDataConfig, securityInitializer) - { - Future = future; - _universeSettings = universeSettings; - } - /// /// The canonical future chain security /// diff --git a/Common/Data/UniverseSelection/OptionChainUniverse.cs b/Common/Data/UniverseSelection/OptionChainUniverse.cs index 190b285d4927..77a20dcd2ae8 100644 --- a/Common/Data/UniverseSelection/OptionChainUniverse.cs +++ b/Common/Data/UniverseSelection/OptionChainUniverse.cs @@ -58,27 +58,6 @@ public OptionChainUniverse(Option option, _optionFilterUniverse = new OptionFilterUniverse(); } - /// - /// Initializes a new instance of the class - /// - /// The canonical option chain security - /// The universe settings to be used for new subscriptions - /// The security initializer to use on newly created securities - /// True if we're running in live mode, false for backtest mode - [Obsolete("This constructor is obsolete because SecurityInitializer is obsolete and will not be used.")] - public OptionChainUniverse(Option option, - UniverseSettings universeSettings, - ISecurityInitializer securityInitializer, - bool liveMode) - : base(option.SubscriptionDataConfig, securityInitializer) - { - Option = option; - _underlyingSymbol = new[] { Option.Symbol.Underlying }; - _universeSettings = new UniverseSettings(universeSettings) { DataNormalizationMode = DataNormalizationMode.Raw }; - _liveMode = liveMode; - _optionFilterUniverse = new OptionFilterUniverse(); - } - /// /// The canonical option chain security /// diff --git a/Common/Data/UniverseSelection/ScheduledUniverse.cs b/Common/Data/UniverseSelection/ScheduledUniverse.cs index 3dec4e069af0..a5f6ad9a1206 100644 --- a/Common/Data/UniverseSelection/ScheduledUniverse.cs +++ b/Common/Data/UniverseSelection/ScheduledUniverse.cs @@ -45,8 +45,7 @@ public class ScheduledUniverse : Universe, ITimeTriggeredUniverse /// Time rule defines what times on each day selected by date rule the universe selection function will be invoked /// Selector function accepting the date time firing time and returning the universe selected symbols /// Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings - /// Security initializer for new securities created via this universe, null will default to algorithm's security initializer - public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, Func> selector, UniverseSettings settings = null, ISecurityInitializer securityInitializer = null) + public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, Func> selector, UniverseSettings settings = null) : base(CreateConfiguration(timeZone, dateRule, timeRule)) { _dateRule = dateRule; @@ -62,9 +61,8 @@ public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule ti /// Time rule defines what times on each day selected by date rule the universe selection function will be invoked /// Selector function accepting the date time firing time and returning the universe selected symbols /// Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings - /// Security initializer for new securities created via this universe, null will default to algorithm's security initializer - public ScheduledUniverse(IDateRule dateRule, ITimeRule timeRule, Func> selector, UniverseSettings settings = null, ISecurityInitializer securityInitializer = null) - : this(TimeZones.NewYork, dateRule, timeRule, selector, settings, securityInitializer) + public ScheduledUniverse(IDateRule dateRule, ITimeRule timeRule, Func> selector, UniverseSettings settings = null) + : this(TimeZones.NewYork, dateRule, timeRule, selector, settings) { } @@ -76,8 +74,7 @@ public ScheduledUniverse(IDateRule dateRule, ITimeRule timeRule, FuncTime rule defines what times on each day selected by date rule the universe selection function will be invoked /// Selector function accepting the date time firing time and returning the universe selected symbols /// Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings - /// Security initializer for new securities created via this universe, null will default to algorithm's security initializer - public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null, ISecurityInitializer securityInitializer = null) + public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null) : base(CreateConfiguration(timeZone, dateRule, timeRule)) { Func func; @@ -95,9 +92,8 @@ public ScheduledUniverse(DateTimeZone timeZone, IDateRule dateRule, ITimeRule ti /// Time rule defines what times on each day selected by date rule the universe selection function will be invoked /// Selector function accepting the date time firing time and returning the universe selected symbols /// Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings - /// Security initializer for new securities created via this universe, null will default to algorithm's security initializer - public ScheduledUniverse(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null, ISecurityInitializer securityInitializer = null) - : this(TimeZones.NewYork, dateRule, timeRule, selector, settings, securityInitializer) + public ScheduledUniverse(IDateRule dateRule, ITimeRule timeRule, PyObject selector, UniverseSettings settings = null) + : this(TimeZones.NewYork, dateRule, timeRule, selector, settings) { } diff --git a/Common/Data/UniverseSelection/Universe.cs b/Common/Data/UniverseSelection/Universe.cs index 2ab6b71bb031..b65652e9a6bc 100644 --- a/Common/Data/UniverseSelection/Universe.cs +++ b/Common/Data/UniverseSelection/Universe.cs @@ -97,16 +97,6 @@ public virtual SubscriptionDataConfig Configuration get; private set; } - /// - /// Gets the instance responsible for initializing newly added securities - /// - /// The SecurityInitializer won't be used - [Obsolete("SecurityInitializer is obsolete and will not be used.")] - public ISecurityInitializer SecurityInitializer - { - get; private set; - } - /// /// Gets the current listing of members in this universe. Modifications /// to this dictionary do not change universe membership. @@ -126,19 +116,6 @@ protected Universe(SubscriptionDataConfig config) Securities = new ConcurrentDictionary(); Configuration = config; - SecurityInitializer = QuantConnect.Securities.SecurityInitializer.Null; - } - - /// - /// Initializes a new instance of the class - /// - /// The configuration used to source data for this universe - /// Initializes securities when they're added to the universe - [Obsolete("This constructor is obsolete because SecurityInitializer is obsolete and will not be used.")] - protected Universe(SubscriptionDataConfig config, ISecurityInitializer securityInitializer) - : this(config) - { - SecurityInitializer = securityInitializer; } /// @@ -334,16 +311,6 @@ internal virtual bool RemoveMember(DateTime utcTime, Security security) return false; } - /// - /// Sets the security initializer, used to initialize/configure securities after creation - /// - /// The security initializer - [Obsolete("SecurityInitializer is obsolete and will not be used.")] - public virtual void SetSecurityInitializer(ISecurityInitializer securityInitializer) - { - SecurityInitializer = securityInitializer; - } - /// /// Marks this universe as disposed and ready to remove all child subscriptions /// diff --git a/Common/Data/UniverseSelection/UserDefinedUniverse.cs b/Common/Data/UniverseSelection/UserDefinedUniverse.cs index 2a677f8599e3..ca2012ed2a99 100644 --- a/Common/Data/UniverseSelection/UserDefinedUniverse.cs +++ b/Common/Data/UniverseSelection/UserDefinedUniverse.cs @@ -62,47 +62,6 @@ public override UniverseSettings UniverseSettings get { return _universeSettings; } } - /// - /// Initializes a new instance of the class - /// - /// The configuration used to resolve the data for universe selection - /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe - /// The interval at which selection should be performed - /// The initial set of symbols in this universe - [Obsolete("This constructor is obsolete because SecurityInitializer is obsolete and will not be used.")] - public UserDefinedUniverse(SubscriptionDataConfig configuration, UniverseSettings universeSettings, ISecurityInitializer securityInitializer, TimeSpan interval, IEnumerable symbols) - : base(configuration, securityInitializer) - { - _interval = interval; - _symbols = symbols.ToHashSet(); - _universeSettings = universeSettings; - _selector = time => _subscriptionDataConfigs.Select(x => x.Symbol).Union(_symbols); - } - - /// - /// Initializes a new instance of the class - /// - /// The configuration used to resolve the data for universe selection - /// The settings used for new subscriptions generated by this universe - /// Initializes securities when they're added to the universe - /// The interval at which selection should be performed - /// Universe selection function invoked for each time returned via GetTriggerTimes. - /// The function parameter is a DateTime in the time zone of configuration.ExchangeTimeZone - [Obsolete("This constructor is obsolete because SecurityInitializer is obsolete and will not be used.")] - public UserDefinedUniverse(SubscriptionDataConfig configuration, UniverseSettings universeSettings, ISecurityInitializer securityInitializer, TimeSpan interval, Func> selector) - : base(configuration, securityInitializer) - { - _interval = interval; - _universeSettings = universeSettings; - _selector = time => - { - var selectSymbolsResult = selector(time.ConvertFromUtc(Configuration.ExchangeTimeZone)); - // if we received an unchaged then short circuit the symbol creation and return it directly - if (ReferenceEquals(selectSymbolsResult, Unchanged)) return Unchanged; - return selectSymbolsResult.Select(sym => Symbol.Create(sym, Configuration.SecurityType, Configuration.Market)); - }; - } /// /// Initializes a new instance of the class /// diff --git a/Configuration/ApplicationParser.cs b/Configuration/ApplicationParser.cs index 41787060d7fb..9cc15ef2a696 100644 --- a/Configuration/ApplicationParser.cs +++ b/Configuration/ApplicationParser.cs @@ -52,9 +52,7 @@ public static Dictionary Parse(string applicationName, string ap { foreach (var commandOption in listOfOptions.Where(option => option.HasValue())) { -#pragma warning disable CS0618 // Type or member is obsolete; Works fine, will use until replacement is required var optionKey = commandOption.Template.Replace("--", ""); -#pragma warning restore CS0618 var matchingOption = options.Find(o => o.Name == optionKey); switch (matchingOption.Type) { diff --git a/Tests/Common/Securities/UniverseManagerTests.cs b/Tests/Common/Securities/UniverseManagerTests.cs index 7bbafdb3cd39..741c16586ba9 100644 --- a/Tests/Common/Securities/UniverseManagerTests.cs +++ b/Tests/Common/Securities/UniverseManagerTests.cs @@ -32,7 +32,7 @@ public void NotifiesWhenSecurityAdded() { var manager = new UniverseManager(); - var universe = new FuncUniverse(CreateTradeBarConfig(), new UniverseSettings(Resolution.Minute, 2, true, false, TimeSpan.Zero), SecurityInitializer.Null, + var universe = new FuncUniverse(CreateTradeBarConfig(), new UniverseSettings(Resolution.Minute, 2, true, false, TimeSpan.Zero), data => data.Select(x => x.Symbol) ); @@ -57,7 +57,7 @@ public void NotifiesWhenSecurityAddedViaIndexer() { var manager = new UniverseManager(); - var universe = new FuncUniverse(CreateTradeBarConfig(), new UniverseSettings(Resolution.Minute, 2, true, false, TimeSpan.Zero), SecurityInitializer.Null, + var universe = new FuncUniverse(CreateTradeBarConfig(), new UniverseSettings(Resolution.Minute, 2, true, false, TimeSpan.Zero), data => data.Select(x => x.Symbol) ); @@ -82,7 +82,7 @@ public void NotifiesWhenSecurityRemoved() { var manager = new UniverseManager(); - var universe = new FuncUniverse(CreateTradeBarConfig(), new UniverseSettings(Resolution.Minute, 2, true, false, TimeSpan.Zero), SecurityInitializer.Null, + var universe = new FuncUniverse(CreateTradeBarConfig(), new UniverseSettings(Resolution.Minute, 2, true, false, TimeSpan.Zero), data => data.Select(x => x.Symbol) ); diff --git a/Tests/Engine/DataFeeds/Enumerators/Factories/BaseDataCollectionSubscriptionEnumeratorFactoryTests.cs b/Tests/Engine/DataFeeds/Enumerators/Factories/BaseDataCollectionSubscriptionEnumeratorFactoryTests.cs index 8ecabcf516b8..22dd60c9d294 100644 --- a/Tests/Engine/DataFeeds/Enumerators/Factories/BaseDataCollectionSubscriptionEnumeratorFactoryTests.cs +++ b/Tests/Engine/DataFeeds/Enumerators/Factories/BaseDataCollectionSubscriptionEnumeratorFactoryTests.cs @@ -48,7 +48,7 @@ public void DoesNotLeakMemory() var universeSettings = new UniverseSettings(Resolution.Daily, 2m, true, false, TimeSpan.FromDays(1)); var securityInitializer = new BrokerageModelSecurityInitializer(new DefaultBrokerageModel(), SecuritySeeder.Null); - var universe = new CoarseFundamentalUniverse(universeSettings, securityInitializer, x => new List{ Symbols.AAPL }); + var universe = new CoarseFundamentalUniverse(universeSettings, x => new List{ Symbols.AAPL }); var fileProvider = new DefaultDataProvider(); @@ -94,7 +94,7 @@ public void ReturnsExpectedTimestamps() var universeSettings = new UniverseSettings(Resolution.Daily, 2m, true, false, TimeSpan.FromDays(1)); var securityInitializer = new BrokerageModelSecurityInitializer(new DefaultBrokerageModel(), SecuritySeeder.Null); - var universe = new CoarseFundamentalUniverse(universeSettings, securityInitializer, x => new List { Symbols.AAPL }); + var universe = new CoarseFundamentalUniverse(universeSettings, x => new List { Symbols.AAPL }); var fileProvider = new DefaultDataProvider();