Skip to content

Inconsistent ordering or universe selection function calls #9435

@DerekMelchin

Description

@DerekMelchin

Expected Behavior

When we add multiple universes to an algorithm, the selection functions fire in the same order that we added the universes to the algorithm.

Actual Behavior

The order in which the universe selection functions are called seem random.

Potential Solution

N/A

Reproducing the Problem

Run this algorithm multiple times:

class MultipleUniverseAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 9, 10)
        self.add_universe(self._select_assets_1)
        self.add_universe(self._select_assets_2)
        self.add_universe(self._select_assets_3)

    def _select_assets_1(self, fundamentals):
        self.log(f"{self.time} - 1")
        return []

    def _select_assets_2(self, fundamentals):
        self.log(f"{self.time} - 2")
        return []

    def _select_assets_3(self, fundamentals):
        self.log(f"{self.time} - 3")
        return []

The log file shows that sometimes the selection functions run in order 2->1->3, sometimes it's 3->2->1.

System Information

QC Cloud

Checklist

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions