'A window of pricing data with adjustments applied assuming that the
end of the window is the day before the current simulation time.
Parameters
assets : iterable of Assets
The assets in the window.
dts : iterable of datetime64-like
The datetimes for which to fetch data.
Makes an assumption that all dts are present and contiguous,
in the calendar.
field : str
The OHLCV field for which to retrieve data.
is_perspective_after : bool
True, if the window is being viewed immediately after the last dt
in the sliding window.
False, if the window is viewed on the last dt.
This flag is used for handling the case where the last dt in the
requested window immediately precedes a corporate action, e.g.:
- is_perspective_after is True
When the viewpoint is after the last dt in the window, as when a
daily history window is accessed from a simulation that uses a
minute data frequency, the history call to this loader will not
include the current simulation dt. At that point in time, the raw
data for the last day in the window will require adjustment, so the
most recent adjustment with respect to the simulation time is
applied to the last dt in the requested window.
An example equity which has a 0.5 split ratio dated for 05-27,
with the dts for a history call of 5 bars with a \'1d\' frequency at
05-27 9:31. Simulation frequency is \'minute\'.
(In this case this function is called with 4 daily dts, and the
calling function is responsible for stitching back on the
\'current\' dt)
|       |       |       |       | last dt | <-- viewer is here |
|       | 05-23 | 05-24 | 05-25 | 05-26   | 05-27 9:31         |
| raw   | 10.10 | 10.20 | 10.30 | 10.40   |                    |
| adj   |  5.05 |  5.10 |  5.15 |  5.25   |                    |
The adjustment is applied to the last dt, 05-26, and all previous
dts.
- is_perspective_after is False, daily
When the viewpoint is the same point in time as the last dt in the
window, as when a daily history window is accessed from a
simulation that uses a daily data frequency, the history call will
include the current dt. At that point in time, the raw data for the
last day in the window will be post-adjustment, so no adjustment
is applied to the last dt.
An example equity which has a 0.5 split ratio dated for 05-27,
with the dts for a history call of 5 bars with a \'1d\' frequency at
05-27 0:00. Simulation frequency is \'daily\'.
|       |       |       |       |       | <-- viewer is here |
|       |       |       |       |       | last dt            |
|       | 05-23 | 05-24 | 05-25 | 05-26 | 05-27              |
| raw   | 10.10 | 10.20 | 10.30 | 10.40 | 5.25               |
| adj   |  5.05 |  5.10 |  5.15 |  5.20 | 5.25               |
Adjustments are applied 05-23 through 05-26 but not to the last dt,
05-27
Returns
out : np.ndarray with shape(len(days between start, end), len(assets))'

def history(self, assets, dts, field, is_perspective_after):

    block = self._ensure_sliding_windows(assets, dts, field, is_perspective_after)
    end_ix = self._calendar.searchsorted(dts[(-1)])
    return concatenate([window.get(end_ix) for window in block], axis=1)
