问题
I was wondering if someone could give me some guidance in setting up my objective.
I am trying to minimise variance in python with some cardinality constraints on the number of assets in my portfolio. I am not sure what package would help me do this. And if there was a working example for the above.
回答1:
Below is a MIQP model that illustrates how we can model a portfolio problem with the number assets limited to be between minAssets and maxAssets. If an asset is in the portfolio, furthermore its fraction is limited to be between fmin and fmax.
In this link you can also see how you can try to solve this problem with just a series of linear MIP problems.
MIQP solvers are readily available: CVXPY/ECOS_BB, Cplex, and Gurobi are a few examples. These are all callable from Python. A simple portfolio QP model would be a good starting point (no doubt such a model is available in the examples for any of these solvers).
回答2:
You may have a look at some links, which are about python package CVXOPT
:
https://cvxopt.org/examples/book/portfolio.html
https://scaron.info/blog/quadratic-programming-in-python.html
来源:https://stackoverflow.com/questions/54288030/mixed-integer-quadratic-programming-in-python