mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-03 00:50:11 +08:00
26fd6fda8b
- Fixes an error where Modeling API data known as of the close of `day N` would be shown to algorithms during `before_trading_start` as of the close of the same day. Algorithms should now only receive data during `before_trading_start/handle_data` that was known as of the simulation time at which the function would be called. - All Term instances now have a `mask` attribute that must be a `Filter` or an instance of `AssetExists()`. `mask` can be used to specify that a Factor should be computed in a manner that ignores the values that were not `True` in the mask. - Changed the interface for `FFCLoader.load_adjusted_array` and `Term._compute` from `(columns, mask)`, with mask as a DataFrame, to `(columns, dates, assets, mask)`, where mask is a numpy array. This is primarily to avoid having to reconstruct extra DataFrames when using masks produced by non `AssetExists` filters. - Adds `BoundColumn.latest`, which gives the most-recently-known value of a column.
16 lines
385 B
Python
16 lines
385 B
Python
"""
|
|
Factor that produces the most most recently-known value of Column.
|
|
"""
|
|
from .factor import CustomFactor
|
|
from ..term import SingleInputMixin
|
|
|
|
|
|
class Latest(SingleInputMixin, CustomFactor):
|
|
"""
|
|
Factor producing the most recently-known value of `inputs[0]` on each day.
|
|
"""
|
|
window_length = 1
|
|
|
|
def compute(self, today, assets, out, data):
|
|
out[:] = data[-1]
|