跳转至

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
  • 'frontier_returns': array of annualised portfolio returns
  • 'frontier_volatilities': array of annualised portfolio volatilities
  • 'frontier_sharpe': array of Sharpe ratios
  • 'frontier_weights': (n_points x N) weight matrix
  • 'min_variance': dict with keys 'weights', 'return', 'volatility'
  • 'max_sharpe': dict with keys 'weights', 'return', 'volatility', 'sharpe'
  • 'asset_names': list of asset names

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 1/N for each asset.

None
max_iter int

Maximum solver iterations.

1000

返回:

类型 描述
dict
  • 'weights': optimal weight array (N,)
  • 'risk_contributions': risk contribution per asset (N,)
  • 'volatility': portfolio annualised volatility
  • 'asset_names': list of asset names

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 objective='target_return'. Annualised target.

None
target_volatility float

Required for objective='target_risk'. Annualised target.

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 -max_weight if shorts allowed).

None
sector_constraints dict

{sector_name: (min_alloc, max_alloc)} pairs.

None
sector_map dict

{asset_name: sector_name} mapping (needed with sector_constraints).

None

返回:

类型 描述
dict
  • 'weights': optimal weight array
  • 'return': annualised expected return
  • 'volatility': annualised volatility
  • 'sharpe': Sharpe ratio
  • 'asset_names': list
  • 'objective': objective used