Performing a rolling vector auto regression with two variables X and Y, with time lag on X in Python
There are some rather quick ways.
I assume you are only interested in the slope and average of the signal Y. In order to calculate these, you need to have:

sum(Y)
sum(X)
sum(X.X)
sum(X.Y)

All sums are over the samples in the window. When you have these, the average is:
sum(Y) / n
and the slope:
(sum(X.Y) - sum(X) sum(Y) / n) / (sum(X.X) - sum(X)^2 / n)
To make a quick algorithm it is worth noting that all of these except for sum(X.Y) can be calculated in a trivial way from either X or Y. The rolling sums are very fast to calculate as they are cumulative sums of differences of two samples ("incoming to window" minus "outgoing from the window").
Only sum(X.Y) needs to be calculated separately for each time step.
All these operations can be vectorized, even though the time lag is probably easier to write as a loop without any notable performance hit. This way you will be able to calculate tens of millions of regressions per second. Is that fast enough?
I have to perform linear regressions on a rolling window on Y and a time lagged version of X, ie finding Y(t) = aX(t-1) + b. The window size is fixed at 30 samples. I want to return a numpy array of all the beta coefficients. Is there a quick way of doing this? I read about the Savitsky-Golay filter, but it regresses only X with the time lagged version of itself. Thanks!