Example,
arr1 = array([0,0,0,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0])
arr2 = array([1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0])
arr2 is almost perfectly correlated with arr1 lagged by 3 time slots.
I'm assuming every time series is of the same length with only binary values.
To get the correlation I've tried swapping the 0-valued entries with -1 and calculating the dot product between the two arrays and then dividing by the length of the time series. I don't know how to find the lag other than to recalculate the correlation using different time shifts, which seems computationally burdensome.