qis.returns_to_nav¶
- qis.returns_to_nav(returns, init_period=0, terminal_value=None, init_value=None, first_date=None, freq=None, constant_trade_level=False, ffill_between_nans=True, is_log_returns=False)[source]¶
Convert returns to NAV time series.
- Parameters:
init_period (int | None) – For pandas input: if 0, set the return on the row before each column’s first non-NaN return to zero when that row exists and is NaN; if 1, set the first non-NaN return to zero; None leaves the returns unchanged. The index is never extended, so a series with no leading NaN row starts its NAV at 1 + the first return
terminal_value (ndarray) – Target terminal NAV value for scaling
init_value (ndarray | float) – Target initial NAV value (default: 1.0)
first_date (Timestamp) – Inclusive date through which observed returns are set to zero; missing observations remain missing. Takes precedence over init_period
freq (str | None) – Resampling frequency
constant_trade_level (bool) – If True, use arithmetic cumsum; if False, use geometric compounding
ffill_between_nans (bool) – Forward-fill NAV between NaN returns while preserving leading and trailing missing regions, including for geometric NumPy inputs
is_log_returns (bool) – If True, convert from log returns
- Returns:
NAV time series on the index of
returns, or on thefreqgrid when given. Before any terminal_value or init_value scaling it starts at 1.0 on a zeroed row and otherwise at 1 + the first return- Return type: