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

Code before:
                    spot_values.append(
                        self._get_current_contract(asset, session_label)
                    )
                else:
                    spot_values.append(
                        self._get_daily_spot_value(asset, field, session_label)
                    )
            else:
                if field == "last_traded":
                    spot_values.append(
                        self.get_last_traded_dt(asset, dt, 'minute')
                    )
                elif field == "price":
                    spot_values.append(
                        self._get_minute_spot_value(
                            asset, "close", dt, ffill=True,
                        )
                    )
                elif field == "contract":
                    spot_values.append(self._get_current_contract(asset, dt))
                else:
                    spot_values.append(
                        self._get_minute_spot_value(asset, field, dt)
                    )

        return spot_values[0] if assets_is_scalar else spot_values

    def get_adjustments(self, assets, field, dt, perspective_dt):
        """
        Returns a list of adjustments between the dt and perspective_dt for the
        given field and list of assets

        Parameters
        ----------
        assets : list of type Asset, or Asset
            The asset, or assets whose adjustments are desired.
        field : {'open', 'high', 'low', 'close', 'volume', \
                 'price', 'last_traded'}
            The desired field of the asset.
        dt : pd.Timestamp
            The timestamp for the desired value.
        perspective_dt : pd.Timestamp
            The timestamp from which the data is being viewed back from.
        data_frequency : str
            The frequency of the data to query; i.e. whether the data is
            'daily' or 'minute' bars

        Returns
        -------
        adjustments : list[Adjustment]
            The adjustments to that field.

Review comment (performance):
I have not profiled it, but always creating the out array may be a place to watch for a performance regression if/when `get_spot_value` is called in a tight loop.

A good way to check is to profile a 'buy and hold' type algorithm over a 500+ sized universe to make sure that that the the position tracker checks for the end of day values does not cause too much of a regression.
(Also the position tracker could be changed to pass a vector of assets, to take advantage of this change.)

Code after:
                    return self._get_current_contract(asset, session_label)
                else:
                    return self._get_daily_spot_value(
                        asset, field, session_label,
                    )
            else:
                if field == "last_traded":
                    return self.get_last_traded_dt(asset, dt, 'minute')
                elif field == "price":
                    return self._get_minute_spot_value(
                        asset, "close", dt, ffill=True,
                    )
                elif field == "contract":
                    return self._get_current_contract(asset, dt)
                else:
                    return self._get_minute_spot_value(asset, field, dt)

        if assets_is_scalar:
            return get_single_asset_value(assets)
        else:
            return list(map(get_single_asset_value, assets))

    def get_adjustments(self, assets, field, dt, perspective_dt):
        """
        Returns a list of adjustments between the dt and perspective_dt for the
        given field and list of assets

        Parameters
        ----------
        assets : list of type Asset, or Asset
            The asset, or assets whose adjustments are desired.
        field : {'open', 'high', 'low', 'close', 'volume', \
                 'price', 'last_traded'}
            The desired field of the asset.
        dt : pd.Timestamp
            The timestamp for the desired value.
        perspective_dt : pd.Timestamp
            The timestamp from which the data is being viewed back from.
        data_frequency : str
            The frequency of the data to query; i.e. whether the data is
            'daily' or 'minute' bars

        Returns
        -------
        adjustments : list[Adjustment]
            The adjustments to that field.
        """
        if isinstance(assets, Asset):
            assets = [assets]

        adjustment_ratios_per_asset = []