I'm using Python/Pandas. Using naive nested for-loops to do Beta calculation for all ~5k stocks by ~5k days (moving window ~250 days) is unbearably slow. Is there any fast and elegant way to accomplish this goal?
Thanks in advance!
Edit: Simply using Numpy instead of Pandas for all the intermediate steps, would speed up the whole process by >10X.