Having a math related issue, and I feel like the solution is obvious but I just can't get it for some reason. Let's say you have four sector ETFs (or stocks, whatever really). You want to maintain those at an allocation of
Fund A: 50%
Fund B: 30%
Fund C: 15%
Fund D: 5%
After a year you have the following allocation
Fund A: 45%
Fund B: 20%
Fund C: 25%
Fund D: 10%
You want to get it back to the original allocation. Let's say that your portfolio is $1,000,000. The rebalancing would be quite easy (just sell 5% of Fund D for example, and put it in Fund A) but there's a slight complication, selling incurs fees and capital gains tax. During the year you also made $100,000 cash (to simplify let's say you kept the entire amount in cash until rebalancing time). So now your portfolio is $1,100,000. Using an inefficient strategy (as far as I can tell) I could sell 15% of my portfolio from the funds that gained, move them into the funds that lost (giving me my original allocation) and then invest the cash according to the original allocation.
However, this seems inefficient. Intuitively, I feel like I should be able to sell less than 15% of my funds because I have cash to rebalance with, but I can't seem to figure out the formula to minimize selling while attaining the original allocation. Any ideas?