pyepo.data.portfolio¶
Synthetic data for portfolio
Functions¶
|
Generate synthetic feature-cost pairs for portfolio optimization. |
Module Contents¶
- pyepo.data.portfolio.genData(num_data: int, num_features: int, num_assets: int, deg: int = 1, noise_level: float = 1, seed: int = 135) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]¶
Generate synthetic feature-cost pairs for portfolio optimization.
Returns the expected returns \(\mathbf{r}\) (the per-instance cost vectors) and a single shared covariance matrix \(\mathbf{\Sigma}\) used in the risk constraint of the predefined portfolio model. The mean returns follow a factor-model structure \(\mathbf{r}_i = \bar{\mathbf{r}}_i + \mathbf{L}\mathbf{f} + 0.01 \tau \boldsymbol{\epsilon}\), where the factor loadings \(\mathbf{L}\) and residual noise are both scaled by
noise_level(\(\tau\)). Unlike the other generators inpyepo.data, portfolio noise is controlled bynoise_levelrather thannoise_width.- Parameters:
num_data – number of data points
num_features – dimension of features
num_assets – number of assets
deg – polynomial degree of the feature-to-return mapping
noise_level – scales factor loadings L and residual noise (tau)
seed – random seed (default 135 for reproducibility)
- Returns:
covariance matrix (np.ndarray), data features (np.ndarray), mean returns (np.ndarray)
- Return type: