From 483012ccf6ee3a8b161d4d3a924bbf72bc5a6b19 Mon Sep 17 00:00:00 2001 From: Jean Bredeche Date: Fri, 21 Apr 2017 14:00:07 -0400 Subject: [PATCH] REF: Make dataportal emit splits that hold Assets, not sids --- zipline/data/data_portal.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/zipline/data/data_portal.py b/zipline/data/data_portal.py index 39250ef1..09860cfc 100644 --- a/zipline/data/data_portal.py +++ b/zipline/data/data_portal.py @@ -1121,24 +1121,24 @@ class DataPortal(object): self._asset_end_dates[sid] = asset.end_date - def get_splits(self, sids, dt): + def get_splits(self, assets, dt): """ Returns any splits for the given sids and the given dt. Parameters ---------- - sids : container - Sids for which we want splits. + assets : container + Assets for which we want splits. dt : pd.Timestamp The date for which we are checking for splits. Note: this is expected to be midnight UTC. Returns ------- - splits : list[(int, float)] - List of splits, where each split is a (sid, ratio) tuple. + splits : list[(asset, float)] + List of splits, where each split is a (asset, ratio) tuple. """ - if self._adjustment_reader is None or not sids: + if self._adjustment_reader is None or not assets: return {} # convert dt to # of seconds since epoch, because that's what we use @@ -1149,7 +1149,9 @@ class DataPortal(object): "SELECT sid, ratio FROM SPLITS WHERE effective_date = ?", (seconds,)).fetchall() - splits = [split for split in splits if split[0] in sids] + splits = [split for split in splits if split[0] in assets] + splits = [(self.asset_finder.retrieve_asset(split[0]), split[1]) + for split in splits] return splits