QuantConnect/Lean · error · ValueError
Asynchronous universe setting is not supported for coarse &
Error message
Asynchronous universe setting is not supported for coarse & fine selections, please use the new Fundamental single pass selection
What it means
FundamentalUniverseSelectionModel (Python) builds a two-stage coarse→fine universe when fundamental_data is false. Lean does not support asynchronous universe settings for paired coarse+fine selection (the fine pass needs the coarse results synchronously), so if the universe_settings.asynchronous flag is true it raises ValueError.
Source
Thrown at Algorithm.Framework/Selection/FundamentalUniverseSelectionModel.py:53
def create_universes(self, algorithm: QCAlgorithm) -> list[Universe]:
'''Creates a new fundamental universe using this class's selection functions
Args:
algorithm: The algorithm instance to create universes for
Returns:
The universe defined by this model'''
if self.fundamental_data:
universe_settings = algorithm.universe_settings if self.universe_settings is None else self.universe_settings
# handle both 'Select' and 'select' for backwards compatibility
selection = lambda fundamental: self.select(algorithm, fundamental)
if hasattr(self, "Select") and callable(self.Select):
selection = lambda fundamental: self.Select(algorithm, fundamental)
universe = FundamentalUniverseFactory(self.market, universe_settings, selection)
return [universe]
else:
universe = self.create_coarse_fundamental_universe(algorithm)
if self.filter_fine_data:
if universe.universe_settings.asynchronous:
raise ValueError("Asynchronous universe setting is not supported for coarse & fine selections, please use the new Fundamental single pass selection")
selection = lambda fine: self.select_fine(algorithm, fine)
if hasattr(self, "SelectFine") and callable(self.SelectFine):
selection = lambda fine: self.SelectFine(algorithm, fine)
universe = FineFundamentalFilteredUniverse(universe, selection)
return [universe]
def create_coarse_fundamental_universe(self, algorithm: QCAlgorithm) -> Universe:
'''Creates the coarse fundamental universe object.
This is provided to allow more flexibility when creating coarse universe.
Args:
algorithm: The algorithm instance
Returns:
The coarse fundamental universe'''
universe_settings = algorithm.universe_settings if self.universe_settings is None else self.universe_settings
return CoarseFundamentalUniverse(universe_settings, lambda coarse: self.filtered_select_coarse(algorithm, coarse))
View on GitHub (pinned to d2c3659f87)
Solutions
- Disable asynchronous selection: set UniverseSettings(..., asynchronous=False) (or omit it) for coarse+fine models.
- Switch to the single-pass Fundamental universe by setting the model's fundamental_data flag / using FundamentalUniverseSelectionModel's fundamental path, which supports async selection.
Example fix
# before self.set_universe_settings(UniverseSettings(asynchronous=True)) self.set_universe_selection(FundamentalUniverseSelectionModel(..., filter_fine_data=True)) # raises # after (coarse+fine, sync) self.set_universe_settings(UniverseSettings(asynchronous=False)) # OR single-pass fundamental (async-safe): # use a FundamentalUniverseSelectionModel subclass with fundamental_data enabled
Defensive patterns
Strategy: validation
Validate before calling
# Ensure coarse+fine uses synchronous selection
settings = algorithm.universe_settings
if getattr(settings, 'asynchronous', False) and using_coarse_fine:
raise ValueError('Disable asynchronous universe settings for coarse+fine, or use single-pass Fundamental') Type guard
def is_async_safe_for_coarse_fine(settings, fundamental_data: bool, filter_fine: bool) -> bool:
if not fundamental_data and filter_fine:
return not getattr(settings, 'asynchronous', False)
return True Prevention
- Leave UniverseSettings.asynchronous False when using coarse+fine selection.
- Use the single-pass Fundamental universe if you need asynchronous selection.
When it happens
Trigger: create_coarse_fundamental_universe() returns a universe whose universe_settings.asynchronous is True, and filter_fine_data is True, so a FineFundamentalFilteredUniverse would be layered on top of an async coarse universe.
Common situations: Overriding algorithm.set_universe_settings(...) with UniverseSettings(asynchronous=True), or passing a custom universe_settings object with asynchronous=True into the model while still using coarse+fine.
Related errors
- MaximumSectorExposureRiskManagementModel.on_securities_chang
- Please overrride the 'select' fundamental function
- Future contracts did not work up as expected: {addedSecurity
- Future contracts did not work up as expected: {addedSecurity
- Universe selection should have been triggered right away. Th
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/5f9ca1d2f58792d4.
Report an issue: GitHub.