Skip to content

Commit

Permalink
Merge pull request #1444 from quantopian/use-session-label-on-daily
Browse files Browse the repository at this point in the history
BUG: Use session label instead of date for 1d.
  • Loading branch information
ehebert committed Aug 29, 2016
2 parents 0ae85eb + 9474ccb commit 22ad891
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion zipline/data/data_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ def _get_history_daily_window(self, assets, end_dt, bar_count,
Internal method that returns a dataframe containing history bars
of daily frequency for the given sids.
"""
days_for_window = self._get_days_for_window(end_dt.date(), bar_count)
session = self.trading_calendar.minute_to_session_label(end_dt)
days_for_window = self._get_days_for_window(session, bar_count)

if len(assets) == 0:
return pd.DataFrame(None,
Expand Down
8 changes: 4 additions & 4 deletions zipline/data/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ def __init__(self, market_opens, minute_reader, trading_calendar):
self._one_min = pd.Timedelta('1 min').value

def _prelude(self, dt, field):
date = dt.date()
session = self._trading_calendar.minute_to_session_label(dt)
dt_value = dt.value
cache = self._caches[field]
if cache is None or cache[0] != date:
market_open = self._market_opens.loc[date]
cache = self._caches[field] = (dt.date(), market_open, {})
if cache is None or cache[0] != session:
market_open = self._market_opens.loc[session]
cache = self._caches[field] = (session, market_open, {})

_, market_open, entries = cache
market_open = market_open.tz_localize('UTC')
Expand Down

0 comments on commit 22ad891

Please sign in to comment.