# How can I choose how much to invest in each stock of my portfolio?

I'm trying to find a mathematical way to decide what percentage of my capital I should invest in each stock of my portfolio to maximize my profit.

Here's my attempt to the solution:

Let's say my portfolio is made of $$n$$ stocks, and let's call $$x_{i}$$ the percentage of the capital invested in the stock, then the percentual profit I get after a certain period of time will be:

$$Profit= \sum_{i=1}^{n} x_{i}p_{i}$$ where $$p_{i}$$ is the expected percentual gain or loss of the $$i^{th}$$ stock.

Maximizing this function constrained by the fact that the $$x_{i}$$'s add up to 1 is a standard task of calculus.

My question is about the way of finding a sensible estimate of the $$p_{i}$$s, I argue I could look at value by which each stock varied over the period of time I'm considering in the past and then take the mean value of that, but it looks a bit naive of an estimate.

Can someone suggest me a cleverer way of doing this?

I hope you are asking about the approach of portfolio structuring rather than the measurement of returns. The former is more interesting because any level of "return" is achievable with leverage, which should incentivize you to incorporate the idea of risk into your problem.

This is a core problem of financial economics, so there is plenty of literature to explore in regards to "clever ways" of doing this. To help get you started, here is a quick intro (most of which you already have the intuition of):

1. At time $$t$$, each stock $$i$$ has a price $$p_{i,t}$$
2. In general, we care about the return $$R_{i,t} = \frac{p_{i, t} + d_{i, t}}{p_{i, t-1}}$$, where $$d_{i,t}$$ represents the dividend of stock $$i$$
3. We typically consider the return to be a random variable $$\tilde{R}_{i,t}$$, and thus care about it's expected return $$E[\tilde{R}_{i,t}]$$
4. Putting all of your $$n$$ stocks together with weights $$w$$ results in a portfolio return $$E[\tilde{R}_{t}] = \sum\limits_{i=1}^n w_i E[\tilde{R}_{i,t}]$$

Now, your question what one should do from here. The classic formulation is not a constrained maximization with the portfolio return as the objective function. This is because such a problem does not account for the risk in your portfolio, by which we mean the variance of the portfolio $$w'Vw = \sum\limits_{i=1}^n \sum\limits_{j=1}^n w_i w_j Cov(R_i, R_j)$$. The basic economic intuition is that the market won't allow you to have high returns without taking high risk.

Thus, the constrained optimization problem is to minimize your portfolio variance subject to a minimum level of return $$\mu$$ and your portfolio weights summing to 1: $$\min\limits_w \frac{1}{2} w'Vw$$ subject to: $$w'E[R] \geq \mu$$ $$w'1 = 1$$

This is the famous Modern Portfolio Theory result by Harry Markowitz. From here, there is plenty of clever work and disagreement on what constitutes the best portfolio, so I leave that to you :D