qis.bfill_timeseries¶
- qis.bfill_timeseries(df_newer, df_older, freq='B', fill_method=None, is_prices=False)[source]¶
Extend newer time series backward with older provider histories.
For price inputs, a provider’s first observed level supplies a zero-return NAV anchor when no usable earlier return exists. A newer all-missing DataFrame column without an older counterpart remains entirely missing.
- Parameters:
df_newer (DataFrame | Series) – Newer Series or DataFrame whose labels and columns define the output. Its rows are interpreted in increasing date order without modifying the caller’s object. A nonempty provider requires a
DatetimeIndexwithoutNaT. A zero-row object retains its declared schema; a zero-column DataFrame is invalid.df_older (DataFrame | Series) – Older object of the same pandas type, used before each newer history begins. Its rows are also interpreted in increasing date order without modifying the caller. A nonempty provider requires a
DatetimeIndexwithoutNaT. A zero-row object or zero-column DataFrame is treated as an unavailable provider.freq (str) – Frequency of the returned date grid.
fill_method (str | None) – Return-gap policy.
Nonepreserves missing returns,'to_zero'fills missing returns with zero after each column begins, and'ffill'carries its last observed return forward. For price inputs, the policy is applied in return space.is_prices (bool) – Whether the supplied data are price levels. First observed provider prices are retained when no earlier return can anchor them, and expanded grids carry the last observed level forward.
- Returns:
Chronologically ordered backfilled data on the requested grid with matching frequency metadata, preserving the newer input’s pandas type, labels, and column order. If one provider has no observations, the available provider supplies the result under the newer schema and existing frequency and fill policies; if both have no observations, an owned empty object with that schema is returned.
- Raises:
TypeError – If a nonempty provider does not use a
DatetimeIndex.ValueError – If a nonempty provider index contains
NaT, the newer DataFrame has no columns, orfill_methodis notNone,'to_zero', or'ffill'.NotImplementedError – If the newer and older inputs are not both Series or both DataFrames.
- Return type: