In order to calculate BETA of a stock for a filter in my algorithm, I'm taking the covariance of the average of the last year of daily close-prices for my asset and SPY, then dividing by the variance of SPY. This is similar to the method found on StackOverflow:
covariance = numpy.cov(asset , SPY) variance = numpy.var(asset) beta = covariance / variance
Does using the last year of daily close-prices as historical data work for finding covariance and variance? Or does this affect these values, and what alternative methods for calculating BETA exist?