qis.bootstrap_price_fundamental_data¶
- qis.bootstrap_price_fundamental_data(price_datas, fundamental_datas, bootstrap_type=BootstrapType.STATIONARY, bootstrap_output=BootstrapOutput.DF_TO_LIST_ARRAYS, num_samples=10, index_length=1000, block_size=30, min_block_size=1, is_log_returns=False, seed=1, is_price_weighted_fundamentals=False, init_to_end=True, is_positive=True)[source]¶
resample price panels and AR(1) fundamentals jointly with one shared index array.
One index array is drawn over the
len(prices.index) - 1return rows of the first price panel and passed tobootstrap_price_data()for every price panel and tobootstrap_ar_process()for every fundamental panel, so the return and the AR innovation drawn at the same index row move together.The two kinds of path start differently and are offset by one step. A price path starts at its anchor (the last positive price with
init_to_end=True, the first row otherwise): row 0 is the anchor and rowthas applied the returns drawn at index rows1..t. A fundamental path starts from the full-sample mean of its data, which is not part of the output: rowthas applied the innovations drawn at index rows0..t. Withis_price_weighted_fundamentals=Trueeach fundamental path is multiplied element by element by the matching path of the first price panel, row by row and column by column.- Parameters:
price_datas (Dict[str, Series | DataFrame]) – price panels keyed by name; the first one sets the index array and must be aligned with every fundamental panel. Every panel must have as many rows as the first
fundamental_datas (Dict[str, Series | DataFrame]) – fundamental panels keyed by name, with the index, and for DataFrames the columns, of the first price panel
bootstrap_type (BootstrapType) – resampling scheme; see
BootstrapTypebootstrap_output (BootstrapOutput) – shape of the results; see
BootstrapOutputnum_samples (int) – number of independent draws
index_length (int) – length of each path
block_size (int) – mean block length for STATIONARY, exact length for FIXED_BLOCK
min_block_size (int) – floor on the drawn block length under STATIONARY
is_log_returns (bool) – resample log returns rather than arithmetic ones
seed (int) – seed for the numba random state
is_price_weighted_fundamentals (bool) – multiply each fundamental path by the matching path of the first price panel
init_to_end (bool) – anchor of the price paths, forwarded to
bootstrap_price_data()is_positive (bool) – positivity rule of the fundamental paths, forwarded to
bootstrap_ar_process()
- Returns:
Tuple of (price paths, fundamental paths), each a dict keyed like its input
- Raises:
ValueError – if a fundamental panel and the first price panel are of different types, if a price panel has fewer rows than the first, or if gaps leave a fundamental panel fewer residual rows than the shared index array reaches
- Return type:
Tuple[Dict[str, DataFrame | List], Dict[str, DataFrame | List]]