Repository: quantopian/zipline
File: tests/test_data_portal.py (Python)

Code before:
            {
                'open': full(len(dts), nan),
                'high': full(len(dts), nan),
                'low': full(len(dts), nan),
                'close': full(len(dts), nan),
                'volume': full(len(dts), 0),
            },
            index=dts))
        asset1_df = pd.concat(dfs)
        yield 1, asset1_df

        asset2_df = pd.DataFrame(
            {
                'open': 1.0055,
                'high': 1.0059,
                'low': 1.0051,
                'close': 1.0055,
                'volume': 100,
            },
            index=asset1_df.index,
        )
        yield 2, asset2_df

    @classmethod
    def make_future_minute_bar_data(cls):
        trading_calendar = cls.trading_calendars['us_futures']
        trading_sessions = cls.trading_sessions['us_futures']
        # No data on first day, future asset intentionally not on the same
        # dates as equities, so that cross-wiring of results do not create a
        # false positive.
        dts = trading_calendar.minutes_for_session(trading_sessions[1])
        dfs = []
        dfs.append(pd.DataFrame(
            {
                'open': full(len(dts), nan),
                'high': full(len(dts), nan),
                'low': full(len(dts), nan),
                'close': full(len(dts), nan),
                'volume': full(len(dts), 0),
            },
            index=dts))
        dts = trading_calendar.minutes_for_session(trading_sessions[2])
        dfs.append(pd.DataFrame(
            {
                'open': append(200.5, full(len(dts) - 1, nan)),
                'high': append(200.9, full(len(dts) - 1, nan)),
                'low': append(200.1, full(len(dts) - 1, nan)),
                'close': append(200.3, full(len(dts) - 1, nan)),
                'volume': append(2000, full(len(dts) - 1, nan)),
            },
            index=dts))

Review comment (suggestion):
We should be pass the `Future` type here to make it clear that we're getting the primary calendar for futures, and in case we ever want change it.

Code after:
            },
            index=dts))
        dts = trading_calendar.minutes_for_session(cls.trading_days[2])
        dfs.append(pd.DataFrame(
            {
                'open': [nan, 103.50, 102.50, 104.50, 101.50, nan],
                'high': [nan, 103.90, 102.90, 104.90, 101.90, nan],
                'low': [nan, 103.10, 102.10, 104.10, 101.10, nan],
                'close': [nan, 103.30, 102.30, 104.30, 101.30, nan],
                'volume': [0, 1003, 1002, 1004, 1001, 0]
            },
            index=dts[:6]
        ))
        dts = trading_calendar.minutes_for_session(cls.trading_days[3])
        dfs.append(pd.DataFrame(
            {
                'open': full(len(dts), nan),
                'high': full(len(dts), nan),
                'low': full(len(dts), nan),
                'close': full(len(dts), nan),
                'volume': full(len(dts), 0),
            },
            index=dts))
        asset1_df = pd.concat(dfs)
        yield 1, asset1_df

        asset2_df = pd.DataFrame(
            {
                'open': 1.0055,
                'high': 1.0059,
                'low': 1.0051,
                'close': 1.0055,
                'volume': 100,
            },
            index=asset1_df.index,
        )
        yield 2, asset2_df

    @classmethod
    def make_future_minute_bar_data(cls):
        trading_calendar = cls.trading_calendars[Future]
        trading_sessions = cls.trading_sessions['us_futures']
        # No data on first day, future asset intentionally not on the same
        # dates as equities, so that cross-wiring of results do not create a
        # false positive.
        dts = trading_calendar.minutes_for_session(trading_sessions[1])
        dfs = []
        dfs.append(pd.DataFrame(
            {
                'open': full(len(dts), nan),
                'high': full(len(dts), nan),