Execution models retain detached consolidators after partial universe removal

Đang mở
#10,102 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.

Ngôn ngữ chính
C#
Star
22.5k
Fork
5.4k
Merge trung bình
22 giờ 6 phút
Pull request đã merge (30 ngày)
81

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của QuantConnect/Lean

Tất cả issue của QuantConnect/Lean

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.