The problem of rebalancing an investement portfolio

linear algebra

I bought $30$ of stock $A$ at a price of 1 USD each. And 2 of sock $B$ at a price of $15$ USD each. Now 50% of my portfolio is stock $A$ ($\frac{30 \times 1}{60}$) and 50% of it is stock $B$ ($\frac{15 \times 2}{60}$). I want to keep this balance, so that each stock is 50% of my portfolio.

A month later prices changed, now $A$ costs 3 USD and $B$ costs $12$ USD. I want to rebalance my portfolio so that each stock contributes 50% of the overall value again. Under some budget $b$, how many of each stock do I have to buy to rebalance my portfolio?

This is a real life problem of mine. I am interested in a general solution: given budget $b$, stock quantities $s_1, s_2, \dots, s_n$, stock prices $c_1, c_2, \dots, c_n$, find how many of each stock to buy $s_1', s_2', \dots, s_n'$ such that each stock contributes a fixed percentage $p_1, p_2, \dots, p_n$.

I tried writing it down as a system of linear equations, but couldn't obtain a general solution from there. Important caveat is that the new obtained percentage does not have to be exact, it should be just close enough. You can't always obtain exactly 50%/50% or any other ratio.

Here's my attempt at a system of equations:
$$c_1(s_1 + s_1') + c_2(s_2 + s_2') + \dots + c_n(s_n + s_n') = S$$
$$c_i(s_i + s_i') = p_i S, \ i \in {1, 2, \dots, n}$$
$$c_1 s_1' + c_2 s_2' + \dots + c_n s_n' \leq b$$

Where $S$ is the total value.

I feel like there should be a simple and beautiful solution, but so far I have only arrived to equations where I need to guess some appropriate values. E.g for the simple problem statement above I have arrived to:
$$3 s_2' – s_1' = 16$$
From here, by substituting random values until it works, I arrive to two (of the many) solutions that restore the balance: $(s_1 = 2, s_2 = 6)$ and $(s_1 = 8, s_2 = 8)$. The problem with that I can't automate picking values until it works, and I can't run such computations every time I need to rebalance a real portfolio of 10 or more stocks.

Best Answer

Given your budget $b$ and the current value of the portfolio $v$, after rebalancing the total portfolio will have value $b+v$. Each stock $i$ should represent $p_i(b+v)$ of the portfolio. Buy or sell enough of it to get to this level.

In your example, $A$ is currently $90$ and $B$ is currently $24$, so $v=114$. If your budget is $36$ the new portfolio value will be $150$, so each stock should represent $75$. You need to sell $15$ worth of $A$ and buy $51$ worth of $B$ to get to balance. Note that the net cost of $51-15=36$ matches your budget.

Related Question