From daf05c6b59c8f264ac0c2288ef5c221ed042550b Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Wed, 20 Jan 2016 06:52:10 -0500 Subject: [PATCH] BUG: Ensure that current_sids() returns Assets instead of identifiers Also batch lookup sids in algo.run --- zipline/algorithm.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/zipline/algorithm.py b/zipline/algorithm.py index a74ee984..bf11cae6 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -559,15 +559,11 @@ class TradingAlgorithm(object): # The sids field of the source is the reference for the universe at # the start of the run - self._current_universe = set() - for source in self.sources: - for sid in source.sids: - self._current_universe.add(sid) + sids = {sid for source in self.sources for sid in source.sids} # Check that all sids from the source are accounted for in # the AssetFinder. This retrieve call will raise an exception if the # sid is not found. - for sid in self._current_universe: - self.asset_finder.retrieve_asset(sid) + self._current_universe = set(self.asset_finder.retrieve_all(sids)) # force a reset of the performance tracker, in case # this is a repeat run of the algorithm.