robertmartin8 / PyPortfolioOpt

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
https://pyportfolioopt.readthedocs.io/
MIT License
4.47k stars 951 forks source link

Changing weights in portfolio_performance #93

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi, I have a question about the possibility of passing the weights variable to ef.portfolio_performance. In the base_optimizer.portfolio_performance the parameter weights exists but in ef it could not be passed. When we use weights = ef.max_sharpe() we could get the weights but changing the values is not possible in the ef.portfolio_performance(True, risk_free_rate). I want to use it not for optimization but for validating some portfolios and get its performance and sharpe ratio on a specific percents of each. Is it a way to change the weights or pass it from the ef.portfolio_performance(self, verbose=False, risk_free_rate=0.02): Thanks for your respond Barmak

robertmartin8 commented 4 years ago

Hi @nojaba,

Thanks for reaching out! If you want to use just the portfolio_performance function independent of any optimizer:

from pypfopt.base_optimizer import portfolio_performance

portfolio_performance(weights, expected_returns_ cov_matrix, verbose=True, risk_free_rate=0.02)

The source code is here. I should probably add this to the docs somewhere!

Best, Robert