From ec6492c84e09ff2f73a5ec0b1d52c92d9b0794df Mon Sep 17 00:00:00 2001 From: Jean Bredeche Date: Mon, 24 Apr 2017 14:15:26 -0400 Subject: [PATCH] TST: New fixture for constant futures data --- zipline/testing/fixtures.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/zipline/testing/fixtures.py b/zipline/testing/fixtures.py index 48bd4ae8..0f54ac12 100644 --- a/zipline/testing/fixtures.py +++ b/zipline/testing/fixtures.py @@ -1186,6 +1186,37 @@ class WithConstantEquityMinuteBarData(WithEquityMinuteBarData): return ((sid, frame) for sid in sids) +class WithConstantFutureMinuteBarData(WithFutureMinuteBarData): + + FUTURE_MINUTE_CONSTANT_LOW = 3.0 + FUTURE_MINUTE_CONSTANT_OPEN = 4.0 + FUTURE_MINUTE_CONSTANT_CLOSE = 5.0 + FUTURE_MINUTE_CONSTANT_HIGH = 6.0 + FUTURE_MINUTE_CONSTANT_VOLUME = 100.0 + + @classmethod + def make_future_minute_bar_data(cls): + trading_calendar = cls.trading_calendars[Future] + + sids = cls.asset_finder.futures_sids + minutes = trading_calendar.minutes_for_sessions_in_range( + cls.future_minute_bar_days[0], + cls.future_minute_bar_days[-1], + ) + frame = pd.DataFrame( + { + 'open': cls.FUTURE_MINUTE_CONSTANT_OPEN, + 'high': cls.FUTURE_MINUTE_CONSTANT_HIGH, + 'low': cls.FUTURE_MINUTE_CONSTANT_LOW, + 'close': cls.FUTURE_MINUTE_CONSTANT_CLOSE, + 'volume': cls.FUTURE_MINUTE_CONSTANT_VOLUME, + }, + index=minutes, + ) + + return ((sid, frame) for sid in sids) + + class WithAdjustmentReader(WithBcolzEquityDailyBarReader): """ ZiplineTestCase mixin providing cls.adjustment_reader as a class level