# Portfolio Optimization with maximum number of Trades constraint

i am currently running linear optimization and maximizing summation of (weight*score) for each assets.

I am running it on assets that are difficult to trade and the universe is easily about 2000 of them every month. My firm has capacity to trade only about 100 of them..

How do i introduce a max number of trade constraints for the assets ? I am thinking of introducing binary variables to indicate whether to trade for each assets but i am not sure how to link it back to the original objective function

Regards James

Let $w_i$ be the weights and $s_i$ the scores. Let $w_i^{max}$ and $w_i^{min}$ be the maximum and minimum allowed weight for asset $i$. Introduce the variables $z_i\in{0,1}$ to indicate whether asset $i$ is in the portfolio, and let $K$ be the maximum number of assets in the portfolio.
The maximization objective is $$max(w_i) \sum_i w_is_i$$ under the weight constraint $$z_iw_i^{min}\leq w_i \leq z_iw_i^{max}$$ and the cardinality constraint $$\sum_i z_i \leq K$$ The weight constraint guarantees that $w_i$ is zero when $z_i$ is zero. There are several numerical packages available to solve this class of optimizations, for example CVXOPT in Python or intlinprog in Matlab.