Skip to content
New issue

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

How to return weights instead of binary numbers for PortfolioOptimizer #421

Open
athanzxyt opened this issue Sep 29, 2022 · 3 comments
Open

Comments

@athanzxyt
Copy link

Hello,

I understand that the PortfolioOptimizer in Qiskit Finance/Optimization can solve quadratic programs such as minimum variance. Following the Qiskit Optimization tutorial. However, it returns binary integers on whether or not to select a stock. How do I change the class code to return a weight that each stock should hold within the portfolio?

https://qiskit.org/documentation/finance/tutorials/01_portfolio_optimization.html

@woodsp-ibm
Copy link
Member

Take a look at this, see if its what you need, which was done some time back qiskit-community/qiskit-finance#57 - there is a unit test added which shows its use etc.

@athanzxyt
Copy link
Author

So to my understanding, we can find integer returns by using PortfolioOptimization.bounds. However, this becomes very costly? Is there a way to return float weights? Or am I misunderstanding something.

@woodsp-ibm
Copy link
Member

The portfolio optimization used to have only a buy or not result for each stock, and was changed to support integer amounts. This is the functionality it has. Now the portfolio optimization code relies on Qiskit Optimization to solve the problem it defines, through the model it creates. You can potentially look at using Qiskit Optimization more directly to define a problem/model that more fits your needs and have it solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants