mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-05 11:57:49 +08:00
ENH: teach BarData about current session's minutes
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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
|
||||
#################
|
||||
|
||||
Reference in New Issue
Block a user