Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Universe Schedule Ignored, Filter Method Invoked Daily on Async Mode

Open jaredbroad opened this issue 3 months ago • 0 comments

Expected Behavior

Regardless of async true or false; LEAN should respect the universe settings for scheduled universe selection.

Actual Behavior

Setting universe to async forces invoke of selection method.

Potential Solution

Review async universe functions to confirm using the settings provided. FromMM: the schedule is enforce after the async selections happened: we can probably invert it

Reproducing the Problem

    public class EtfUniverseAlgorithm : QCAlgorithm
    { 
        public override void Initialize()
        {
            SetCash(100000);
            SetStartDate(2020, 1, 1); 
            SetEndDate(2021, 1, 1);
            Settings.AutomaticIndicatorWarmUp = true; 
            
            // Universe Initialization
            UniverseSettings.Asynchronous = true; // FALSE RESPECTS Schedule; TRUE is daily schedule.
            UniverseSettings.Resolution = Resolution.Minute;
            UniverseSettings.Schedule.On(DateRules.MonthStart());
            AddUniverse(Universe.ETF("QQQ", Market.USA, UniverseSettings, ETFConstituentsFilter)); 
        } 

        private IEnumerable<Symbol> ETFConstituentsFilter(IEnumerable <ETFConstituentUniverse> constituents)
        {
            var topAssets = (from s in constituents
                            orderby s.Weight descending
                            select s.Symbol).Take(10); 
            Debug($"New assets selected {constituents.First().Time.ToString()}");
            return topAssets;
        }
    }
Image

Checklist

  • [x] I have completely filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues
  • [x] I have provided detailed steps to reproduce the issue

jaredbroad avatar Oct 07 '25 20:10 jaredbroad