Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: teach BarData about current session's minutes #1713

Merged
merged 1 commit into from Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/test_bar_data.py
Expand Up @@ -234,6 +234,18 @@ def test_current_session(self):
bar_data.current_session
)

def test_current_session_minutes(self):
first_day_minutes = self.trading_calendar.minutes_for_session(
self.equity_minute_bar_days[0]
)

for minute in first_day_minutes:
bar_data = self.create_bardata(lambda: minute)
np.testing.assert_array_equal(
first_day_minutes,
bar_data.current_session_minutes
)

def test_minute_before_assets_trading(self):
# grab minutes that include the day before the asset start
minutes = self.trading_calendar.minutes_for_session(
Expand Down
6 changes: 6 additions & 0 deletions zipline/_protocol.pyx
Expand Up @@ -757,6 +757,12 @@ cdef class BarData:
direction="next"
)

property current_session_minutes:
def __get__(self):
return self._trading_calendar.minutes_for_session(
self.current_session
)

#################
# OLD API SUPPORT
#################
Expand Down