Execution models retain detached consolidators after partial universe removal

Aperta
#10,102 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

priority:p2

Problem

The VWAP and standard-deviation execution models can retain a detached consolidator when a symbol leaves one universe but remains in another universe with a different subscription configuration. The symbol never leaves the algorithm in this case.

Security.Subscriptions retains the removed configuration, including its consolidator, even though that configuration is absent from the subscription service. A later selection by the first universe therefore makes the cached consolidator look attached when it is not receiving data.

This is a pre-existing partial-membership case, distinct from #10007's complete departure/reselection; it also reproduces with the models before #10098.

Reproduction and observations

Use SPY minute data from 2020-02-10 through 2020-04-09 with two scheduled universes:

  1. Universe A uses regular-hours subscriptions, selects SPY until 2020-02-14, then selects it again from 2020-03-23 onward.
  2. Universe B always selects SPY, using minute subscriptions with extended_market_hours=True.
  3. Give the scheduled universes different trigger times, such as 00:00 and 00:01, so they have distinct universe symbols.
  4. Use the Python VWAP execution model. Open a 10-share position before A deselects SPY. Liquidate it on 2020-02-20 so A's deferred subscription removal can complete while B still holds SPY as a member.
  5. On A's reselection, give the execution model a PortfolioTarget(SPY, -10).

Tested end to end. At reselection, the sum of consolidators in security.subscriptions was 1, but the sum in algorithm.subscription_manager.subscription_data_config_service.get_subscription_data_configs(symbol) was 0. The model retained the original SymbolData, and no execution-model sell occurred through 2020-04-09. The same configuration without universe B rebuilds the model and sells on 2020-03-23.

Code path

  • Engine/DataFeeds/UniverseSelection.cs:674-697 removes A's membership and data feed but skips Security.Reset() and security removal because B keeps the security active.
  • Engine/DataFeeds/DataManager.cs:389-407,539-550 removes the feed/config from the service, without removing its reference from the security's subscription collection.
  • Common/Securities/Security.cs:79-85 returns the retained collection.
  • On A's reselection, UniverseSelection.cs:629-633 finds a value-equal configuration in that collection and does not replace the old reference. The new live feed uses a different configuration object.
  • Both execution models and their Python ports retain their cached symbol data. Looking for the cached consolidator only in Security.Subscriptions does not distinguish this state from a live registration.

Required outcome

When a model's actual feeding subscription has been removed, a subsequent addition must reconnect/rebuild its symbol data even when another universe kept the symbol active. A suggested narrow fix is to base consolidator-liveness checks on the current subscription service configurations, rather than the security's retained collection. If the subscription collection itself is corrected instead, other universes' live configurations must remain intact.

Add regression coverage with overlapping universes and different subscription configurations. Keep the same minute resolution in this reproduction so resolution-selection behavior is not a second variable.

Priority P2: verified wrong execution behavior in a specific multi-universe setup, without evidence of widespread current impact. Evidence of affected live algorithms would raise the priority.

Lingua principale
C#
Stelle
22.5k
Fork
5.4k
Merge medio
22h 6m
PR unite (30g)
81

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di QuantConnect/Lean

Tutte le issue di QuantConnect/Lean

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.