Repository navigation
Create data subscriptions for re-selected user defined members - #9930
Open
Divyansh151005 wants to merge 1 commit into
Open
Divyansh151005 wants to merge 1 commit into
Divyansh151005 wants to merge 1 commit into
Conversation
Adding a new resolution to a security already in the user defined universe, or removing and re-adding it at a new resolution in the same time step, kept the same selected symbols. Universe.PerformSelection then returned Unchanged and ApplyUniverseSelection skipped existing members, so the new configurations never reached the data manager and the old feed kept running. ApplyUniverseSelection now syncs the selected members of a user defined universe before the unchanged check: it adds the requested configurations the data feed does not have yet and removes this universe's request for the ones it no longer requests. Other universes keep the current path. Fixes QuantConnect#9900.
4 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adding a new resolution to a security that is already in the user defined universe (
AddEquity("SPY", Resolution.Tick)afterAddEquity("SPY", Resolution.Minute)), or removing it and re-adding it at a new resolution in the same time step, records the new configuration onSecurity.Subscriptionsbut never creates its data subscription. The algorithm keeps the old bars and gets no ticks.The selected symbols are the same in both cases, so
Universe.PerformSelectionreturnsUnchangedandApplyUniverseSelectionreturns before the "find new selections" loop. That loop would skip the symbol anyway because it is already a member. On the remove and re-add path the symbol is still selected, so the removal loop keeps the member and its old feed.ApplyUniverseSelectionnow syncs the selected members of aUserDefinedUniversebefore the unchanged check:security.AddData, the currency feed removal,DataManager.AddSubscriptionandInternalSubscriptionManager.AddedSubscriptionRequest.RemoveSubscription(config, universe)only drops this universe's request, so a feed another universe still uses stays.Coarse, fundamental and chain universes keep the current path, since their configurations do not change for an existing member. A user defined universe only runs selection when its collection changes or on its trigger times, so the extra work per selection is one
GetSubscriptionRequestscall per member.Related Issue
Fixes #9900
Motivation and Context
The issue was reported from a live deployment: switching a held symbol to tick resolution silently did nothing. The cloud backtest in the issue shows SPY and QQQ receiving minute bars and no ticks after the switch, while IWM (new symbol) and AAPL (fundamental universe member) receive ticks.
Requires Documentation Change
No.
How Has This Been Tested?
UniverseSelectionTests.AddingResolutionToExistingUserDefinedSecurityCreatesDataSubscription: SPY at minute, thenAddEquity("SPY", Resolution.Tick). It asserts the minute feed stays and the tick feed is created. It fails on master.UniverseSelectionTests.RemoveAndReaddAtNewResolutionInOneTimeStepReplacesDataSubscription: QQQ at minute, thenRemoveSecurityplusAddEquity("QQQ", Resolution.Tick)in one time step. It asserts the minute feed is dropped, the tick feed exists, and QQQ is tradable. It fails on master.UserDefinedUniverseResolutionChangeRegressionAlgorithm(C#, local AIG and BAC tick and minute data on 2013-10-07). At 15:00 it adds tick resolution to AIG and removes and re-adds BAC at tick. It asserts AIG gets ticks and keeps its minute bars, BAC gets ticks and no minute bars after the switch, and BAC is tradable. On master it throwsExpected AIG ticks after adding the tick resolution(1,576 data points processed). With the fix it completes with 307,906 data points.Local runs (macOS, .NET 10):
The one failure is
InternalSubscriptionManagerTests.UniverseSelectionAddAndRemove(TravisExclude), a 15 second wall clock live test. It times out the same way on master locally, so it is not related. The full suite is left to CI.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>