qiskit-optimization icon indicating copy to clipboard operation
qiskit-optimization copied to clipboard

How to return weights instead of binary numbers for PortfolioOptimizer

Open athanzxyt opened this issue 3 years ago • 3 comments

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

athanzxyt avatar Sep 29 '22 01:09 athanzxyt

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

woodsp-ibm avatar Sep 29 '22 13:09 woodsp-ibm

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.

athanzxyt avatar Nov 15 '22 14:11 athanzxyt

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.

woodsp-ibm avatar Nov 15 '22 19:11 woodsp-ibm