Hello,
I am a student and I have been trying to run a linear regression between the "overnight returns" and the "returns of the first 30 minutes of Trading" of the day after over the period of time 2007-2017 for the SPY. This is what I wrote so far:
#overnight indexing
start1 = '2007-01-01 15:59:00'
end1 = '2017-01-01 15:59:00'
SPYclosing = get_pricing('SPY', fields='price', start_date=start1, end_date=end1)
start2 = '2007-01-02 09:30:00'
end2 = '2017-01-02 09:30:00'
SPYinitial = get_pricing('SPY', fields='price', start_date=start2, end_date=end2)
rate_return_overnight=(SPYclosing-SPYinitial)/SPYinitial
print rate_return_overnight
and:
#first 30 minutes return indexing
start3 = '2007-01-01 09:30:00'
end3 = '2017-01-01 09:30:00'
SPYopening = get_pricing('SPY', fields='price', start_date=start3, end_date=end3)
start4 = '2007-01-01 10:00:00'
end4 = '2017-01-01 10:00:00'
SPYfirst30mins = get_pricing('SPY', fields='price', start_date=start4, end_date=end4)
rate_return_first30mins=(SPYfirst30mins-SPYopening)/SPYopening
print rate_return_overnight
The problem is that it keeps giving me a column of zeros and when I try to use it in the linear regression, as explained in the lessons:
https://www.quantopian.com/posts/quantopian-lecture-series-linear-regression
It just doesn't work and it gives me a lot of NaNs in the summary of the results.
Can anyone help me on making me understand where my mistake is?
Thanks a lot in advance