0

I am trying to create a calculator that allows users to specify asset classes (e.g. 500 in fund1, 500 in fund2, etc.) and the desired fraction of the total portfolio per asset class (e.g. 70% in fund1, 30% in fund2). The equation should determine how much to buy or sell per asset class (instead of move).

I have the following formula for when only 1 fund changes, where $X_1$ is before, $X_2$ is after, and $dX$ is their difference. The same applies to the second fund $Y$. $a$ is the desired fraction of $X$.

if $X_2 = a (X_2 + Y)$ and $X_2 = dX + X1$ is true, then $dX + X_1 = a (X_2 + Y)$. Rewriting that gave me: $$ dX = \frac{aX_1 - X_1 + aY}{1-a} $$


With $X_1 = 50$, $a = 0.70$, and $Y = 50$; $dX$ will be $66.5$.

Now imagine a situation where users can enter multiple funds and the corresponding desired fraction at will. Now, whenever I calculate the amount to buy in one fund, the total changes, and any previous calculations need to be redone. It seems like I need a way to combine these equations.

Is there a name for this type of problem? Can anyone point me in the right direction? My apologies for the possible lack of proper tagging or wording, it has been a while since I did maths... Thanks!
Paul Sinclair
  • 43,643
Koen
  • 101
  • I'm sorry, but this is very confusing. I think I can figure out what you mean about asset classes, though the wording is bizarre. But by the definition you gave, $dX = X_2 - X_1$, not whatever that formula is supposed to be. You appear to be calculating something else, but what, I can't tell. The formula makes no sense that I can see, even if you fix the missing parenthesis and other issues. (Was one of the $X_1$s supposed to be $X_2$? You said $Y$ doesn't change in this formula, so why is there a $Y_2$? How come $Y_2$ is being multiplied by the desired fraction $a$ for $X$?) – Paul Sinclair Dec 18 '21 at 15:13
  • Understandably so... I clarified the post and explained how I got to the equation. – Koen Dec 19 '21 at 08:46

1 Answers1

1

The normal way to do this is to calculate the current value $P$ of the complete portfolio. Then for each fund $i$ multiply it by the target fraction $a_i$ for that fund. This gives the target holding $X_i$ in fund $i$. Then $dX_i$ is the difference between between the target holding and the current holding in fund $i$.

This allows you to calculate the needed changes for all funds at once.

Paul Sinclair
  • 43,643