get_grid_portfolios
- EfficientFrontier.get_grid_portfolios(step=0.1, max_points=100000)
Generate rebalanced portfolios for all weight combinations on a grid.
Weights are enumerated with a fixed step that must divide 1.0 evenly (e.g. 0.05, 0.10, 0.20, 0.25, 0.50). Per-asset
boundsare respected.- Parameters:
- stepfloat, default 0.10
Weight increment (e.g. 0.10 for 10 %).
- max_pointsint, default 100_000
Guardrail on the number of grid portfolios. The point count grows combinatorially with the number of assets and
1 / step; an oversized request raisesValueErrorbefore enumeration instead of hanging. Raise it to allow larger grids at the cost of runtime.
- Returns:
- DataFrame
Table with Risk (annualized std) and CAGR for every grid portfolio.
Examples
>>> ls_m = ["SPY.US", "GLD.US"] >>> x = ok.EfficientFrontier( ... assets=ls_m, ... first_date="2005-01", ... last_date="2020-11", ... ccy="USD", ... rebalancing_strategy=ok.Rebalance(period="year"), ... ) >>> grid = x.get_grid_portfolios(step=0.25) >>> grid.head() CAGR Risk 0 ... ...