Correlation Matrix:
Correlation Matrix:
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.
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.

 Roundtable Knight
 Posts: 138
 Joined: Wed Nov 10, 2004 4:36 pm
I would suggest you use R, http://addictedtor.free.fr/graphiques/R ... ?graph=137
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
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 doublecheck 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.
 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, 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 doublecheck 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.
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.
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.
Use Blox Builder
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
Of course you must have the builder edition to do this modification and some programming skills.
/Mats

 Site Admin
 Posts: 8715
 Joined: Tue Apr 06, 2004 1:41 pm
 Location: Boston, MA
 Contact:
Re: Correlation Matrix:
This block will print your current correlation matrix: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.
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
If your correlation issue isn't resolved, CSI has a correlationonly 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 shorterterm 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.
I'm having some developers build a solution for me using VBA in Excel to allow shorterterm 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.

 Roundtable Knight
 Posts: 229
 Joined: Thu Jul 08, 2010 2:36 pm
 Location: Boulder, CO
 Contact:
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.
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
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.