qis.align_weights_to_columns¶
- qis.align_weights_to_columns(weights, columns)[source]¶
align a weight specification to a set of instrument columns.
A Dict or pd.Series is aligned by name, so the order of the specification does not matter and a column the specification does not name carries nan, which every consumer treats as no position. A List or np.ndarray is positional and must match the column count, since there is no name to align on. This is the normaliser
generate_static_weights_schedule()andqis.backtest_model_portfolioshare, so that one weight argument means one thing.- Parameters:
- Returns:
weights indexed by
columns, nan where the specification does not name a column- Raises:
ValueError – if a named specification carries a name outside
columns, or a positional specification does not match the number of columns or is not one dimensionalNotImplementedError – if
weightsis of an unsupported type
- Return type: