fincore.optimization¶
Efficient Frontier¶
fincore.optimization.frontier.efficient_frontier(returns, n_points=50, risk_free_rate=0.0, short_allowed=False, max_weight=1.0)
¶
Compute the mean-variance efficient frontier.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
returns
|
DataFrame
|
Asset returns (T x N). Columns = asset names. |
必需 |
n_points
|
int
|
Number of points on the frontier. |
50
|
risk_free_rate
|
float
|
Annual risk-free rate (used for Sharpe calculation). |
0.0
|
short_allowed
|
bool
|
Whether short selling is allowed. |
False
|
max_weight
|
float
|
Maximum weight per asset. |
1.0
|
返回:
| 类型 | 描述 |
|---|---|
dict
|
|
Risk Parity¶
fincore.optimization.risk_parity.risk_parity(returns, risk_budget=None, max_iter=1000)
¶
Compute risk-parity portfolio weights.
Each asset's marginal risk contribution is equalised (or matched to a user-supplied risk budget).
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
returns
|
DataFrame
|
Asset returns (T x N). |
必需 |
risk_budget
|
ndarray
|
Target risk budget per asset (sums to 1).
Defaults to equal budget |
None
|
max_iter
|
int
|
Maximum solver iterations. |
1000
|
返回:
| 类型 | 描述 |
|---|---|
dict
|
|
Optimize¶
fincore.optimization.objectives.optimize(returns, objective='max_sharpe', risk_free_rate=0.0, target_return=None, target_volatility=None, short_allowed=False, max_weight=1.0, min_weight=None, sector_constraints=None, sector_map=None)
¶
Solve a constrained portfolio optimisation problem.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
returns
|
DataFrame
|
Asset returns (T x N). |
必需 |
objective
|
str
|
One of 'max_sharpe', 'min_variance', 'target_return', 'target_risk'. |
'max_sharpe'
|
risk_free_rate
|
float
|
Annual risk-free rate. |
0.0
|
target_return
|
float
|
Required for |
None
|
target_volatility
|
float
|
Required for |
None
|
short_allowed
|
bool
|
Allow negative weights. |
False
|
max_weight
|
float
|
Upper bound per asset. |
1.0
|
min_weight
|
float
|
Lower bound per asset. Defaults to 0 (or |
None
|
sector_constraints
|
dict
|
|
None
|
sector_map
|
dict
|
|
None
|
返回:
| 类型 | 描述 |
|---|---|
dict
|
|