StockFetcher Forums · Filter Exchange · Is there any way to determine the correlation between two stocks?<< >>Post Follow-up
Kevin_in_GA
4,599 posts
msg #89319
Ignore Kevin_in_GA
3/9/2010 1:54:28 PM

In StockFetcher, that is.

There is a function in the yepher documentation called "r-squared" which returns the correlation coefficient for a single stock (how close to a straight line has the price been trending over a given period of time).

I would like to determine how well correlated two different stocks are - for example QQQQ and SPY, or GLD and SLV. I have not yet figured out a trick to do this.

My first though was to simply define the ratio of the stock price to the price of the SPY as a new data set, and use something like the following:

set{priceratio, close / ind(SPY, close)}

then use the r-squared function on the new variable priceratio:

set{correlation, ind(priceratio, r-squared(30))}

but as you can see this doesn't really work:

Fetcher[

symlist(spy,qqqq,dia,gld,slv)
set{priceratio, close / ind(SPY,close)}
set{correlation, ind(priceratio, r-squared(30))}

draw correlation
]



They all are the same - even SPY with itself, which should be a perfect fit.

Any thoughts on how one can get this correlation?


chetron
2,817 posts
msg #89320
Ignore chetron
3/9/2010 2:29:04 PM

maybe....


Fetcher[
draw relative strength(drys,30)

close above .1
volume above 1000000
]



Kevin_in_GA
4,599 posts
msg #89323
Ignore Kevin_in_GA
3/9/2010 3:17:42 PM

Thanks, Chet. I looked at this one already, and what it does is to compare the %gain in the individual stock for the period defined against the gain in the SPX for the same period. If it is above 1, the stock perfomed better than the index.

What it explicitly states is that it is not a pattern matching tool, which is another way of saying the two stocks move in an identical fashion over a set period of time (high correlation between price).

I am trying to find a way to measure correlations between two similar stocks, and be able to play a hedged strategy based on a change in the correlation (which historically will revert to the mean for proper pairs).

StockFetcher Forums · Filter Exchange · Is there any way to determine the correlation between two stocks?<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.