Calculating correlations
Author: sedelstein
Creation Date: 3/29/2015 11:26 PM
profile picture

sedelstein

#1
I need help with a problem that I believe likely has something to do with the SetContext method.

I am trying to get correlations between (in this example) 3 symbols over the last 10 years
AAL, AAPL, and ADBE

AAL has 327 bars while AAPL and ADBE both have 2517 bars

In the following code, I am trying to print out ALL the correlations available for the full 10 years
I expected that for the first 2517 - 327 bars I would get the correlations between AAPL and ADBE and the other two would result in NaN's as there is no early data available for AAL

When I fiddle with the SetContext function, I find I need it set to false the first time to get all the history (else I get just 327 correlations for all 3 pairs)

In the second instance, I still only get 327 dates but depending on true or false, I get early or later dates but I am unable to get ALL dates.

Is there a fix you can suggest?

Thanks

CODE:
Please log in to see this code.
profile picture

sedelstein

#2
What I'm really looking to do is after I get all the pairwise correlations for a data set (some of which have more data and some less) is to go through each day and pull out the ones on a given date where data exists.

I'm unclear on how to do it and any suggestions appreciated.

sympair1 sympair2 sympair 3
Date1 nan nan 0.95
Date2 nan nan 0.94
.
.
.
.Date n 0.93 0.86 0.93

etc.....


Thanks in advance.
profile picture

sedelstein

#3
Related to this as I am trying to get all pairwise correlations of the Nasdaq 100 going back in time, is it possible to synchronize two external symbols to each other rather than the primary symbol?

I am running the following over 1500 bars and the number (count) of historical correlation series changes with each symbol in the dataset

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).