'The close field\'s aggregation returns the latest close at the given
dt.
If the close for the given dt is `nan`, the most recent non-nan
`close` is used.
If there has been no data on or before the `dt` the close is `nan`.
Returns
np.array with dtype=float64, in order of assets parameter.'

def closes(self, assets, dt):

    (market_open, prev_dt, dt_value, entries) = self._prelude(dt, 'close')
    closes = []
    session_label = self._trading_calendar.minute_to_session_label(dt)
    def _get_filled_close(asset):
        '\n                                                Returns    the    most    recent    non-nan    close    for    the    asset    in    this\n                                                session.    If    there    has    been    no    data    in    this    session    on    or    before    the\n                                                `dt`,    returns    `nan`\n                                                '
        window = self._minute_reader.load_raw_arrays(['close'], market_open, dt, [asset])[0]
        try:
            return window[(~ np.isnan(window))][(-1)]
        except IndexError:
            return np.NaN
    for asset in assets:
        if (not asset.is_alive_for_session(session_label)):
            closes.append(np.NaN)
            continue
        if (prev_dt is None):
            val = self._minute_reader.get_value(asset, dt, 'close')
            entries[asset] = (dt_value, val)
            closes.append(val)
            continue
        else:
            try:
                (last_visited_dt, last_close) = entries[asset]
                if (last_visited_dt == dt_value):
                    closes.append(last_close)
                    continue
                elif (last_visited_dt == prev_dt):
                    val = self._minute_reader.get_value(asset, dt, 'close')
                    if pd.isnull(val):
                        val = last_close
                    entries[asset] = (dt_value, val)
                    closes.append(val)
                    continue
                else:
                    val = self._minute_reader.get_value(asset, dt, 'close')
                    if pd.isnull(val):
                        val = _get_filled_close(asset)
                    entries[asset] = (dt_value, val)
                    closes.append(val)
                    continue
            except KeyError:
                val = self._minute_reader.get_value(asset, dt, 'close')
                if pd.isnull(val):
                    val = _get_filled_close(asset)
                entries[asset] = (dt_value, val)
                closes.append(val)
                continue
    return np.array(closes)
