0

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.

0

2 Answers 2

2

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.

enter image description here

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).

Sign up to request clarification or add additional context in comments.

Comments

0

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

5 Comments

thanks for this but I am trying to add cardinality constraints i dont think i can use cvxopt for this. If i can please can you point me to an example. i am trying to limit the number of names preferably by group. For example in a 5 stock example I have 3 tech stocks and 2 non tech stocks I would like to limit each sector (tech and non tech) to have 2 stocks each
You mean that you want that each time some weights will be strongly equal to 0 ?
yes or have the flexibility to set hte lower bounds
in a typical minimum variance optimization, i have some long only constraints, i have a sum constraint equal to 1, and i have some sector sum constraints. I would like to incorporate the number of stock constraints
And based on what conditions you want to force some weights to be equal 0 ? I mean you will fix some condition for each portfolio rebalance ? I can suggest to fix some threshold of minimum weight and if for some asset weight is less than this threshold, just replace it with 0 and correspondigly adjust other weights.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.