# How to enumerate all the possible portfolios with a given target volatility?

Let's say I have $n$ assets and their returns are stored in a matrix $X \in \mathbb{R}^{m \times n}$ (i.e. I have $m$ returns for each of them.

The covariance matrix of the returns is $\Sigma \in \mathbb{R}^{n \times n}$.

I define a portfolio $w \in \mathbb{R}^{n}$ and I want that $\sum_{i=1}^n w_i=1$.

My goal is to find all the portfolios such that the volatility of the portfolio is some target $\sigma^*$.

So my problem looks like this:

Find all $w$ such that: $\sqrt{w' \Sigma w}=\sigma^*$.

I think that in most cases, I would have an infinity of solutions as long as $\sigma^*$ was chosen decently with regards to the assets available.

What algorithm could help me to find them all? How would the result be represented? I was thinking it should give me some kind of vector space.

-
What if you just generated random portfolios, scaled their weights to 1, then blended that with the risk-free return to generate the target volatility? – John Dec 21 '12 at 3:52
would you be ok with getting results where the actual portfolio standard deviation lies within a band of your target volatility? Computationally/Mathematically, I would claim there is no way around an iterative approach. I am sure there does not exist a closed form solution. – Matt Wolf Dec 21 '12 at 5:29
@John I'm not trying to find a portfolio which can give me this volatility, I'm trying to find all the possible portfolios. – SRKX Dec 21 '12 at 8:20
@Freddy Yes, I would be open to iterative solutions. But I think anything that's not analytic will not allow use to express all portfolios with volatility $\sigma^*$. – SRKX Dec 21 '12 at 8:29
@SRKX, sorry I am still working in my spare time on it, not getting something satisfactory yet. – Matt Wolf Dec 21 '12 at 11:16

Let's say you have $N$ available portfolio elements, and you have (arbitrarily) chosen a weight vector $w^{(i_3,\dots,i_{N})}$ for $N-2$ of them. At this point, the equation

$$w^{\prime}\Sigma w={\sigma^*}^2$$

$$a {w^{(1)}}^2 +b {w^{(1)}} +c =0$$

in the final weight $w^{(1)}=1-w^{(2)}$ for the last remaining indexes. If it has any real roots, then you have one of your family of solutions. If not, then your initial choice was not on a linear subspace intersecting the hypersurface of solutions.

This is actually pretty trivial to handle, even symbolically, for $N=3$. For higher dimensions, I'm not sure if one obtains a nice matrix-algebra formula or not.

Alternatively, you can take the eigenvectors/principal components $p_i$ of your correlation matrix, and consider the problem in that space. Here, the overall variance is going to be

$$\sum_{i=1}^N a_i \nu_i^2$$

for eigenvalues $\nu_i$. Given weights on a subset of $N-2$ of them (without loss of generality, indexes 3 through $N$), you can take

$$\sum_{i=3}^N a_i \nu_i^2 = s^2$$

and you are then solving

$$a_1 \nu_1^2 + (1-a_1) \nu_2^2 = {\sigma^*}^2-s^2$$

for $a_1$, which manifests the explicit restriction ${\sigma^*}^2>s^2$ and solves to

$$a_1 = \frac{ {\sigma^*}^2-s^2 -\nu_2^2 }{(\nu_1^2 - \nu_2^2)}$$.

-