Phorgy Phynance

Archive for the ‘Visualization’ Category

Visualizing Market Risk: A Physicist’s Perspective

with 3 comments

Physicists learn at an early age (sometimes while still in diapers) about vectors. In fact, I supported myself financially through undergrad largely by explaining vectors to physical therapy students. Physics was the “weeder” course and PT students basically needed an “A” to get into the program. Tutoring them was quite lucrative, but that is another story. Here, I present a very neat way to visualize market risk in terms of arrows… err… I mean vectors.

What is a vector?

A vector can be thought of conceptually as an “arrow”.


What is the information contained in an arrow? There are two basic bits of information contained in an arrow

  1. Length or magnitude
  2. Direction

In terms of direction, probably what is more useful than “absolute” direction, is the “relative” direction, which can be quantified as the angle between two arrows.


Multiplying a Vector by a Number

The next thing you need to know about vectors is that you can multiply a vector A by a number \alpha to get another vector \alpha A.


Multiplying a vector by a number merely “rescales” the arrow, i.e. changes its length, while keeping the direction unchanged.

Adding Vectors

Next, given two vectors A and B, there is a rule for adding the arrows to get a new vector X = A+B. There are a couple different ways to visualize the addition of arrows. One involves drawing the vectors “tail to tail” and forming a parallelogram. The new vector is the arrow going across the diagonal as shown below


Alternatively, but equivalently, you can draw the vectors “head to tail” and the new vector is the arrow pointing from the tail of the first arrow to the head of the second arrow as shown below


It doesn’t matter which you choose. Just remember that the addition of arrows is a little funky and involves parallelograms.

If I haven’t lost anyone up to this point, I will be quite impressed if you stick around for what comes next.

The Dot Product

Both the length and relative direction of a vector, or arrow, can be determined by something that we lovingly refer to as the “dot product”. Later in academic life, I learned that the “dot product” was actually a twice covariant symmetric non-degenerate tensor, but I digress. For our purposes, we just need know that the dot product takes two arrows and spits out a number (in a bilinear fashion). In other words, if

X = \alpha A + \beta B and Y = \gamma C + \delta D,


X\cdot Y = \alpha \gamma A\cdot C + \alpha\delta A\cdot D + \beta \gamma B\cdot C + \beta \delta B\cdot D

A fundamental property of the dot product is that when you take the dot product of a vector with itself, the result is the square of the length of the vector, i.e.

\text{Length of } A = |A| = \sqrt{A\cdot A}.

Therefore, the dot product provides us with one of the most important characteristics of a vector: it’s length. To whet your appetite a little, I hope that the expression above makes you think of “variance” or more specifically “standard deviation/volatility”. That is no coincidence!

The dot product of two distinct vectors also gives some very useful information

A\cdot B = |A||B| \cos\theta


\cos\theta = \frac { A\cdot B } { |A||B| } .

Note that \cos\theta lies between +1 and -1. Kind of like correlation. Again, not a coincidence!

Projecting One Arrow Onto Another

Once you start doodling with a bunch of arrows, you may start to think about the relationship between two arrows and, like a shadow, how might one arrow project onto another as shown below


If you recall a bit of trigonometry, the length of B_{\text{Along }A} is given by

|B_{\text{Along }A}| = |B|\cos\theta,

which may be written in terms of the dot product as

|B_{\text{Along }A}| = \frac{A\cdot B}{|A|}.

How about the ratio of that projection? That is determined by simply dividing the above by |A|, i.e.

\text{Ratio of the Projection} = \frac{ A\cdot B }{ |A|^2 }.

This ratio is particularly of interest in finance, as I will show below, and is related to “portfolio beta”.

Portfolio Return as an Arrow

Now the fun starts and I hope at least one person in the universe reads this far down πŸ™‚

The return of a portfolio is a vector.


Well, hear me out. Consider a portfolio consisting on N securities. The return of the portfolio can be expressed in terms of the returns of the securities as follows

R_{\text{Portfolio}} = \sum_{i=1}^N \omega_i R_i,

where \omega_i is the weight of the ith security in the portfolio.

Hmm, the security returns are multiplied by numbers and then added together. That sounds a whole lot like a vector to me!

Ok. If returns can be thought of as arrows, what are the meanings of the length and relative directions of two returns?

As we saw above, to determine the length and relative direction, we needed a dot product. What would be a good dot product for the vector space of security returns?

Covariance as a Dot Product

Technically speaking, covariance does not satisfy all the axioms of a dot product, but fortunately physicists like to shoot from the hip and tend to be right under most practical circumstances and in exotic cases where we are not right, we can usually change things around a bit so that we are right. So technical arguments aside, I am simply going to tell you that covariance can be thought of as a dot product on the vector space of security returns.

Woohoo! That is great. Why? Because all the nice pictures above can be re-interpreted in the context of portfolios of securities.

Here is an arrow depicting the return of a portfolio


What information is conveyed by the length of this arrow? Recall that

\text{Length of }R_{\text{Portfolio}} = \sqrt{R_{\text{Portfolio}}\cdot R_{\text{Portfolio}}},

but if the dot product is covariance, then we get the very interesting association

\text{Length of }R_{\text{Portfolio}} = \sigma_{\text{Portfolio}},

i.e. the length of the arrow is the volatility of the return.

Next, consider the return of a benchmark against which this portfolio is to be measured. The benchmark return can similarly be represented as an arrow and we have


What is the meaning of the angle between the “portfolio arrow” and the “benchmark arrow”? Recall that

\cos\theta = \frac{ R_{\text{Portfolio}}\cdot R_{\text{Benchmark}} } {|R_{\text{Portfolio}}||R_{\text{Benchmark}}|}.

However, we also just learned that

|R_{\text{Portfolio}}| = \sigma_{\text{Portfolio}}

so that the above expression can be rewritten as

\cos\theta = \frac{ \text{cov}(R_{\text{Portfolio}}, R_{\text{Benchmark}}) }{\sigma_{\text{Portfolio}} \sigma_{\text{Benchmark}} },

which you might recognize as the definition of correlation. The correlation between the portfolio return and the benchmark return is the cosine of the angle between the portfolio arrow and the benchmark arrow.

That is pretty neat, eh? We now have a nice way to visualize both the volatility and correlation of security returns. The length of a “return arrow” is its volatility and the angle between two returns relates to their correlation. I couldn’t make up a better story if I tried πŸ™‚

But what can we do with this knowledge?

Tracking Error

The excess return of a portfolio of its benchmark is simply

\Delta  R = R_{\text{Portfolio}} - R_{\text{Benchmark}} ,

which we can trivially rearrange as

R_{\text{Portfolio}} = R_{\text{Benchmark}} + \Delta  R

The right hand side of the equation of above represents the addition of two arrows, which we already described above. Therefore, we can represent the expression visually as


This little trick seems kind of neat, but fairly trivial, so what did it give us? Recall that the length of an arrow is its volatility. Recall also that tracking error is defined as the volatility of the excess return, therefore we have the very cool consequence

\text{Tracking Error} = \text{Length of }\Delta R .

We have a very concise way to visualize tracking error that captures both the volatility of the portfolio and the volatility of the benchmark as well as the correlation between the two in one simple diagram.

Portfolio Beta

“Now how much would you pay? But wait! There’s more!”

The same diagram above that gave you tracking error also gives you your portfolio beta. To see this, simply recall the definition of the projection of an arrow along another arrow and reinterpret that in terms of returns

|R_{\text{Portfolio along Benchmark}}| = |R_{\text{Portfolion}}| \cos\theta


\sigma_{\text{Portfolio along Benchmark}} = \sigma_{\text{Portfolion}} \times\rho,

where \rho is the correlation between the portfolio and benchmark returns.

Next, if we consider the ratio of this projection to the length of the benchmark arrow, we have

\frac{ \sigma_{\text{Portfolio along Benchmark}}  }{ \sigma_{\text{Benchmark}} } = \frac{ \sigma_{\text{Portfolion}} }{ \sigma_{\text{Benchmark}} }\times\rho ,

which you might recognize as the definition of the portfolio beta! Therefore,

\text{Portfolio Beta} = \text{Ratio of the Projection}.


We’ve demonstrated, first, that returns can be visualized as arrows where the length of the arrow represents its volatility and the angle between two arrows represents the correlation of the two respective returns. Second, by comparing the portfolio and benchmark returns pictorially, we automatically get a very informative picture of both tracking error and portfolio beta (in one shot) that also contains information about the absolute market risk in terms of the volatilities (lengths) of the portfolio and benchmark arrows as well as the correlation between them.

Written by Eric

February 10, 2008 at 12:34 am