Integer solution that approximates a desired stock split
Let $d_i$ be the desired dollar amount that you'd ideally like to have invested in the $i$th stock (i.e., $d_1,\dots,d_n$ represent the ideal/model portfolio, without taking the requirement to avoid fractional shares).  Let $p_i$ denote the price of a single share of the $i$th stock.

Then you want to find a solution to the following optimization problem

$$\begin{align*}
\text{minimize } &amp;(p_1 x_1 - d_1)^2 + \dots + (p_{20} x_{20} - d_{20})^2\\
\text{subject to } &amp;p_1 x_1 + \dots + p_{20} x_{20} = 10,000\\
                   &amp;x_1 \ge 0, \dots, x_{20} \ge 0
\end{align*}$$

where you require that the variables $x_1,\dots,x_{20}$ be integers.  Here the $p_i$'s and $d_i$'s are given (they are known constants), and you've solving for the $x_i$'s.

This is an instance of quadratic integer programming: i.e., integer programming with linear constraints and a quadratic objective function.  That in turn is a special case of mixed-integer quadratic programming (MIQP).  In general MIQP allows the problem to contain some integer variables and some continuous variables; your particular instance has only integer variables, so it's a special case of MIQP.  You can find off-the-shelf MIQP solvers out there.  I would recommend that you try applying one to your problem.  Given the problem size you describe, I would expect them to be effective and efficient at your problem.

If you wanted to measure the deviation from the ideal model by the $L_1$ distance (sum of absolute values of differences) instead of the $L_2$ distance (sum of squared differences), that could be expressed as an instance of integer linear programming (ILP), for which solvers are even more effective.