We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What are you trying to do? Clear description of the problem you are trying to solve with PyPortfolioOpt
What have you tried?
What data are you using? What asset class, how many assets, how many data points. Preferably provide a sample of the dataset as a csv attachment.
In this excel, the returns are in sheet "sheet1" and covariance matrix is in sheet "cov".
I am trying to do a basic mean variance optimization using ef.min_volatility() but errors
OptimizationError: Please check your objectives/constraints or use a different solver.
I also tried using non-convex optimization in the cookbook example, but the result ended up being the 1/n weights.
target_risk = 0.05 ef = EfficientFrontier(mu, S, weight_bounds=(0, 0.5))
weight_constr = {"type": "eq", "fun": lambda w: np.sum(w)-1}
risk_constr = { "type": "eq", "fun": lambda w: target_risk ** 2 - np.dot(w.T, np.dot(ef.cov_matrix, w)), } constraints = [weight_constr, risk_constr]
ef.nonconvex_objective( lambda w, mu: -w.T.dot(mu), # min negative return i.e max return objective_args=(ef.expected_returns,), weights_sum_to_one=True, constraints=constraints,
)
weights = ef.clean_weights() weights
COV.xlsx
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What are you trying to do?
Clear description of the problem you are trying to solve with PyPortfolioOpt
What have you tried?
What data are you using?
What asset class, how many assets, how many data points. Preferably provide a sample of the dataset as a csv attachment.
In this excel, the returns are in sheet "sheet1" and covariance matrix is in sheet "cov".
I am trying to do a basic mean variance optimization using ef.min_volatility() but errors
OptimizationError: Please check your objectives/constraints or use a different solver.
I also tried using non-convex optimization in the cookbook example, but the result ended up being the 1/n weights.
target_risk = 0.05
ef = EfficientFrontier(mu, S, weight_bounds=(0, 0.5))
Weights sum to zero
weight_constr = {"type": "eq", "fun": lambda w: np.sum(w)-1}
Portfolio vol less than target vol
risk_constr = {
"type": "eq",
"fun": lambda w: target_risk ** 2 - np.dot(w.T, np.dot(ef.cov_matrix, w)),
}
constraints = [weight_constr, risk_constr]
ef.nonconvex_objective(
lambda w, mu: -w.T.dot(mu), # min negative return i.e max return
objective_args=(ef.expected_returns,),
weights_sum_to_one=True,
constraints=constraints,
)
weights = ef.clean_weights()
weights
COV.xlsx
The text was updated successfully, but these errors were encountered: