Page **1** of **1**

### Correlation Matrix:

Posted: **Wed Jul 21, 2010 5:49 am**

by **aj1**

Correlation Matrix:

So I have a portfolio of say 6 instruments. I am interested in looking at their correlation matrix. Can someone please tell me how I can produce a correlation matrix for these 6 instruments â€“ thanks.

Posted: **Wed Jul 21, 2010 7:58 am**

by **babelproofreader**

Posted: **Wed Jul 21, 2010 8:06 am**

by **sluggo**

Since I don't trade stocks, I haven't calculated a stock correlation matrix myself. However I do imagine that the correlations you want to compute, require some price data for each of the stocks. Probably you, the analyst, will need to choose

- The start date (and start time, if using intraday data)
- The end date (and end time, if using intraday data)
- The granularity of the data: monthly? weekly? daily? 60 minute bars? 10 minute bars?

Then you would need to assemble this price data for all stocks in the portfolio to be analyzed, and make sure there are no missing data points (due to trading halts, data vendor glitches, different holidays at different exchanges, etc).

Then you, the analyst, will need to decide whether to calculate correlation upon PRICES, or upon PRICE RETURNS. It is a topic that sometimes inflames powerful emotions and/or strong opinions; here is a discussion of the topic on another quant site

http://www.wilmott.com/messageview.cfm? ... adid=42932
Finally, for the correlation calculation itself, you could use the =CORREL() function built into Microsoft Excel

(ref.1) (ref.2) (ref.3). Or if you decide to calculate it another way, you can double-check your results on a few examples or test cases. You could calculate them (your way) and also calculate them (with Excel), to reassure yourself that your computations aren't buggy.

Posted: **Wed Jul 21, 2010 10:39 am**

by **aj1**

Thank you sluggo & babelproofreader, for your comments & response.

I am perhaps guilty of not making my question clear. My question is:

I am putting some serious thoughts to portfolio composition whilst I develop a system to trade a collection of Futures instruments. The portfolio consists of Indices, currencies & metals â€“ I wish to examine a correlation matrix in order to make some rational decisions about portfolio composition.

My question is â€“ does TB provide a facility for displaying a correlation matrix for a given portfolio of instruments. TB is perhaps the most extensive tool in the market I am surprised this facility is not standard.

sluggo I will most likely also test out the correlation values in excel.

I am looking to pull together a diversified portfolio with low correlation to each other whilst maintaining the integrity of the system (i.e. positive mathematical expectation).

Any thoughts most graciously accepted.

Thanks.

Posted: **Wed Jul 21, 2010 10:46 am**

by **LeviF**

If you have access to the blox marketplace there is a block there that may do what you want.

### Use Blox Builder

Posted: **Tue Aug 03, 2010 8:23 am**

by **Mats**

There is a blox named "Update Dynamic Correlations, you can modify that blox and dump the correlation matrix.

Of course you must have the builder edition to do this modification and some programming skills.

/Mats

### Re: Correlation Matrix:

Posted: **Tue Aug 03, 2010 2:47 pm**

by **Tim Arnold**

aj1 wrote:Correlation Matrix:

So I have a portfolio of say 6 instruments. I am interested in looking at their correlation matrix. Can someone please tell me how I can produce a correlation matrix for these 6 instruments â€“ thanks.

This block will print your current correlation matrix:

viewtopic.php?t=3214
You can set the correlations manually in the Futures Dictionary or you can dynamically compute the correlations using the Update Dynamic Correlations block. Note that the bars used to compute the correlation is important since what is correlated over the last 20 years is not necessarily correlated over the last 20 bars. And when things go really bad, everything becomes correlated.

### Correlations on CSI

Posted: **Mon Feb 21, 2011 5:11 pm**

by **dwitkin**

If your correlation issue isn't resolved, CSI has a correlation-only offering for $99 per year. Its not perfect -- gives 2, 5, 10, 15, and 20 year correlations, so you should question the relevance for short term systems. Also, their system doesn't allow you to indicate that you are short a given instrument, which changes the correlation of the overall portfolio. You can get a sense visually of how going short would impact the portfolio, but its imperfect.

I'm having some developers build a solution for me using VBA in Excel to allow shorter-term futures portfolio VaR calculations (based on Monte Carlo analysis), among other functions -- should be more accurate than correlations. Send me a message if you're interested and I can shoot you a note when it is completed.

Posted: **Mon Feb 21, 2011 5:25 pm**

by **Eventhorizon**

It is trivial to use R to open your actual futures files and generate a complete

correlation matrix and displayit as a heat map.

With a few lines of code you can do a Monte Carlo analysis to estimate VAR.

It is worth examining the covariance of the outliers to get a sense of what happens when the market gets into crisis mode - I am working on a post discussing how to do this.

### Using R for Monte Carlo / Correlation Analysis

Posted: **Tue Feb 22, 2011 7:44 am**

by **dwitkin**

I'll look forward to reading it... please let me know when it's ready / where it is posted.

Eventhorizon wrote:It is trivial to use R to open your actual futures files and generate a complete

correlation matrix and displayit as a heat map.

With a few lines of code you can do a Monte Carlo analysis to estimate VAR.

It is worth examining the covariance of the outliers to get a sense of what happens when the market gets into crisis mode - I am working on a post discussing how to do this.

Posted: **Tue Feb 22, 2011 8:30 am**

by **kianti**

Excel could do the job as well.

Posted: **Tue Feb 22, 2011 3:11 pm**

by **bobsyd**

Or, if you can use Marketplace blox, you might want to try Print_Correlations_Date rev3.tbx in the Correlation & Risk Limiter Blox thread.