From ea1fb05676fb7215ce217adf7c0b7324cf1be264 Mon Sep 17 00:00:00 2001 From: Jean Bredeche Date: Wed, 15 Mar 2017 13:40:33 -0400 Subject: [PATCH] ENH: teach BarData about current session's minutes --- tests/test_bar_data.py | 12 ++++++++++++ zipline/_protocol.pyx | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/tests/test_bar_data.py b/tests/test_bar_data.py index bf13540d..53910361 100644 --- a/tests/test_bar_data.py +++ b/tests/test_bar_data.py @@ -234,6 +234,18 @@ class TestMinuteBarData(WithCreateBarData, 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( diff --git a/zipline/_protocol.pyx b/zipline/_protocol.pyx index 9c1d48f9..d2b1a220 100644 --- a/zipline/_protocol.pyx +++ b/zipline/_protocol.pyx @@ -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 #################