RamtaJogi— Hacking Life for Money and Fame.

RamtaJogi header image 1

Introducing Co-relation Calculator

October 13th, 2008 · 7 Comments · General

NOTE: This was the first release of Co-Relation calculator. You can always find the latest version of this tool on this page.

For quite some time now, JV has been looking for a way to relate a stock with an index. What he wants to know is how does stock A move corresponding to an index B? If index B is green for the day, does stock A also end up on green OR there is no relationship between the two? What he wanted was an indicator over 100 days in percentage which shows how many times stock A followed particular index. E.g. ABK and DJI. In last 100 trading days, how many times if DJI was green, ABK was green and if DJI was red, ABK was red? Intuition suggests that they a big company stock should follow DJI more or less but JV doesn’t like intuition and he wanted real hard numbers.

Now, I might suck at trading for now, I think I am good at programming and I decided to take up JV’s challenge and today in around 3 hours I created a program which lets you relate a stock with an index. Introducing ….drumrolls please….Co-relation Calculator! Here’s a screenshot:

Corelation Calculator Startup

Co-relation Calculator Start up

As I am currently long on ABK, when the program starts it loads ABK and DJI. It also loads 1st day of current year as From Date and Today’s date as To Date. When you click on ‘Get Co-relation Percentage’, program will download prices from Yahoo! Finance and decide for each day whether the tickers were GREEN or RED and whether those movement was same for both the tickers. Let’s try to see how ABK moved with DJI.

Corelation Calculator - ABK / DJI

Co-relation Calculator - ABK / DJI

Interesting. From Jan 1st 2008, 36% of the time, ABK moved same as DJI. You can safely say that ABK doesn’t really follow DJI that much. Let’s compare ABK’s performance against XLF (Financial Sector Index).

Corelation Calculator - ABK - XLF

Co-relation Calculator - ABK - XLF

Well, Looks like ABK follows XLF much more closely. Again, this is as per expectation. BTW, if you have any doubts about the calculation, you can click on ‘Details’ button and it will show you all the prices which program downloaded for calculating the co-relation. [You can also copy this data on clipboard and later paste in Excel for more analysis.]

Corelation Calculator - Details

Co-relation Calculator - Details

I would like to add that program is generic enough so that you can not only compare a stock with an index, but you can compare any two tickers. e.g. ABK and MBI [both are re-insurers]. Well, 48% of the time, they follow each other!

Similarly, GS/MER – 50%, BAC/WFC – 51.75% so on and so forth.
For stocks which are not related, MSFT/AIG – 40%, GOOG/PMI 39%.

Anyway, I am not very sure how useful this information is. Because if a stock follows a particular index ~50% of the times, it doesn’t give me any additional information for my trading. It is useful for scenarios where you find stocks which either follows index very closely OR doesn’t follow index at all. I could not find any combination where stock wasn’t following index. Please try this program and see if you find otherwise.

Program Highlights:

1. It is written in C#/WinForms/.NET Framework 2.0 If you are using Vista, you shouldn’t have any trouble running it. If you are using Windows XP, make sure you have .NET framework installed.

2. It downloads data from Yahoo Finance. Currently, URL for the Yahoo! Finance is hard coded in the program. So if Yahoo! Finance changes their URL or format, program will not work.

3. To download the program, click here. [It's a zip file containing an EXE. Don't worry, there are no viruses or anything.]

So JV, where is my reward? :)

Happy Trading.

Status as of end of Oct 13th:

Positions traded for Gain: None

Positions traded for Loss: None

Open Positions: ABK (LONG 250 @ 3.68$)

7 responses so far ↓

  • 1 YngvaiMalmsteve // Oct 13, 2008 at 11:50 pm

    WOW! That’s cool.

    I would say something like this is helpful, because if you’re thinking about playing a stock, you can get an idea of how closely it follows the overall market. If you have a stock that tends to follow the overall market more closely, then if you’re in a situation where it’s going one way but the market is going the other, your odds may not be as good.

  • 2 Susan Kishner // Oct 14, 2008 at 12:01 am

    Great Blog post. I am going to bookmark and read more often. I love the Blog template

  • 3 Nirav Lakhani // Oct 14, 2008 at 12:09 am

    Ramta!

    This is awesome man. Major respect for the programming prowess. I have wanted a tool like this for so long! I’ll be sure to report back any interesting correlations.

    lakhanin

  • 4 RJ // Oct 14, 2008 at 1:27 am

    Thank you folks.

    Steve, for most of the stocks I looked at, they follow the index for 50% of the times. IMHO, that won’t add much value.

    Susan,

    Thank you for stopping by. I use a theme similar to what you are using, I have customized it a little bit more.

    And Nirav, I would love to hear your thoughts after you have used the program.

  • 5 johnnyvento // Oct 14, 2008 at 7:38 pm

    Ramta you are a man among men- a leader, a warrior, a scholar, and a programmer.

    Send me your address to my gmail acct and I will send you something- probably a gift certificate of some sort.

    Plus I’ll write a blog post about it after I test it out a bit.

    Hurray!

  • 6 johnnyvento // Oct 14, 2008 at 7:52 pm

    that’s freakin’ awesome man. I’m getting a lot of errors though probably because I’m checking a lot of indexes that yahoo doesn’t have.

    Here is the list from prophet
    http://www.prophet.net/learn/indexsymbols.jsp

    you don’t need to change what you have, I just need to see what is available from yahoo.

  • 7 johnnyvento // Oct 14, 2008 at 10:49 pm

    can you break it down into 4 columns:
    1green/2green (%)
    1red/2red (%)
    1red/2green (%)
    1green/2red (%)

    that way we could look down into the stats to find any interesting patterns- I think combining all 4 is washing the data out too much

Leave a Comment