4

I am building software for an investment manager. The investment manager invests money on behalf of his clients.

The investment manager has a model portfolio, of say 20 stocks, each with certain weightage.

Eg: His model portfolio can look like this:

{GOOG: .03, AAPL: 0.4, MSFT: 0.25, TESLA: 0.5, IBM: 0.1, .....} Now lets say the investment manager has one client, who holds all of the stocks, the total of which is worth, say USD50,000, but with slightly different weightage:

{GOOG: .0295, AAPL: 0.415, MSFT: 0.232, TESLA: 0.1, IBM: 0.2, .....} Now the client wants to invest a lumpsum, lets say USD10,000.

Now, the investment manager wants to split this USD10,000 across 20 stocks, so that he gets closest to the model portfolio. i.e. I want the resultant USD60,000 to be split in a way that is closest to the ratios maintained in the model portfolio.

A limitation here is that, I can buy or sell a minimum of 1 stock; I cannot deal in fractions of stocks.

Is there a name for this kind of problem? I am pretty sure this has been solved by someone, so do not want to reinvent the wheel.

I do not know what I should google for, or where to start from.

I want the chosen allocation to have the least deviation from the model portfolio, measured by $L_2$ distance (sum of squared differences). Also, the investor keeps investing periodically, so there is a chance his portfolio might deviate further and further, so the idea is to keep these "tracking errors" to a minimum, so that it the investor's portfolio is as close to the model portfolio as possible.

D.W.
  • 167,959
  • 22
  • 232
  • 500
ashwnacharya
  • 143
  • 6

1 Answers1

3

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 } &(p_1 x_1 - d_1)^2 + \dots + (p_{20} x_{20} - d_{20})^2\\ \text{subject to } &p_1 x_1 + \dots + p_{20} x_{20} = 10,000\\ &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.

D.W.
  • 167,959
  • 22
  • 232
  • 500