Lean
Lean copied to clipboard
Universe Schedule Ignored, Filter Method Invoked Daily on Async Mode
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;
}
}
Checklist
- [x] I have completely filled out this template
- [x] I have confirmed that this issue exists on the current
masterbranch - [x] I have confirmed that this is not a duplicate issue by searching issues
- [x] I have provided detailed steps to reproduce the issue