'Public API method that returns a dataframe containing the requested
history window.  Data is fully adjusted.
Parameters
assets : list of zipline.data.Asset objects
The assets whose data is desired.
bar_count: int
The number of bars desired.
frequency: string
"1d" or "1m"
field: string
The desired field of the asset.
data_frequency: string
The frequency of the data to query; i.e. whether the data is
\'daily\' or \'minute\' bars.
ffill: boolean
Forward-fill missing values. Only has effect if field
is \'price\'.
Returns
A dataframe containing the requested data.'

def get_history_window(self, assets, end_dt, bar_count, frequency, field, data_frequency, ffill=True):

    if ((field not in OHLCVP_FIELDS) and (field != 'sid')):
        raise ValueError('Invalid    field:    {0}'.format(field))
    if (frequency == '1d'):
        if (field == 'price'):
            df = self._get_history_daily_window(assets, end_dt, bar_count, 'close', data_frequency)
        else:
            df = self._get_history_daily_window(assets, end_dt, bar_count, field, data_frequency)
    elif (frequency == '1m'):
        if (field == 'price'):
            df = self._get_history_minute_window(assets, end_dt, bar_count, 'close')
        else:
            df = self._get_history_minute_window(assets, end_dt, bar_count, field)
    else:
        raise ValueError('Invalid    frequency:    {0}'.format(frequency))
    if (field == 'price'):
        if (frequency == '1m'):
            data_frequency = 'minute'
        elif (frequency == '1d'):
            data_frequency = 'daily'
        else:
            raise Exception('Only    1d    and    1m    are    supported    for    forward-filling.')
        assets_with_leading_nan = np.where(isnull(df.iloc[0]))[0]
        (history_start, history_end) = df.index[[0, (-1)]]
        initial_values = []
        for asset in df.columns[assets_with_leading_nan]:
            last_traded = self.get_last_traded_dt(asset, history_start, data_frequency)
            if isnull(last_traded):
                initial_values.append(nan)
            else:
                initial_values.append(self.get_adjusted_value(asset, field, dt=last_traded, perspective_dt=history_end, data_frequency=data_frequency))
        df.ix[(0, assets_with_leading_nan)] = np.array(initial_values, dtype=np.float64)
        df.fillna(method='ffill', inplace=True)
        normed_index = df.index.normalize()
        for asset in df.columns:
            if (history_end >= asset.end_date):
                df.loc[((normed_index > asset.end_date), asset)] = nan
    return df
