Repository: quantopian/zipline
File: zipline/data/data_portal.py (Python)

Code before:
        reader = self._get_pricing_reader('minute')
        try:
            result = reader.get_value(
                asset.sid, dt, column
            )
        except NoDataOnDate:
            if not ffill:
                if column == 'volume':
                    return 0
                else:
                    return np.nan

        if not ffill:
            return result

        # we are looking for price, and didn't find one. have to go hunting.
        last_traded_dt = reader.get_last_traded_dt(asset, dt)

        if last_traded_dt is pd.NaT:
            # no last traded dt, bail
            if column == 'volume':
                return 0
            else:
                return np.nan

        # get the value as of the last traded dt
        result = reader.get_value(
            asset.sid,
            last_traded_dt,
            column
        )

        if np.isnan(result):
            return np.nan

        if dt == last_traded_dt or dt.date() == last_traded_dt.date():
            return result

        # the value we found came from a different day, so we have to adjust
        # the data if there are any adjustments on that day barrier
        return self.get_adjusted_value(
            asset, column, last_traded_dt,
            dt, "minute", spot_value=result
        )

    def _get_daily_spot_value(self, asset, column, dt):
        reader = self._get_pricing_reader('daily')
        if column == "last_traded":
            last_traded_dt = reader.get_last_traded_dt(asset, dt)

            if isnull(last_traded_dt):

Review comment (suggestion):
Not part of this change. But I just noticed that this particular check on `date` does not play well with adjustments of Futures.

Code after:
        reader = self._get_pricing_reader('minute')

        if ffill:
            # If forward filling, we want the last minute with values (up to
            # and including dt).
            query_dt = reader.get_last_traded_dt(asset, dt)

            if pd.isnull(query_dt):
                # no last traded dt, bail
                if column == 'volume':
                    return 0
                else:
                    return np.nan
        else:
            # If not forward filling, we just want dt.
            query_dt = dt

        try:
            result = reader.get_value(asset.sid, query_dt, column)
        except NoDataOnDate:
            if column == 'volume':
                return 0
            else:
                return np.nan

        if not ffill or (dt == query_dt) or (dt.date() == query_dt.date()):
            return result

        # the value we found came from a different day, so we have to adjust
        # the data if there are any adjustments on that day barrier
        return self.get_adjusted_value(
            asset, column, query_dt,
            dt, "minute", spot_value=result
        )

    def _get_daily_spot_value(self, asset, column, dt):
        reader = self._get_pricing_reader('daily')
        if column == "last_traded":
            last_traded_dt = reader.get_last_traded_dt(asset, dt)

            if isnull(last_traded_dt):
                return pd.NaT
            else:
                return last_traded_dt
        elif column in OHLCV_FIELDS:
            # don't forward fill
            try:
                return reader.get_value(asset, dt, column)
            except NoDataOnDate:
                return np.nan
        elif column == "price":