Here is an attempt to render Kaufman's Efficiency Ratio in Zipline / Quantopian. Any comments, improvements etc gratefully accepted. Quantopian - you may want to incorporate the corrected / improved version in Zipline and Quantopian.
class efficiency_ratio(CustomFactor):
inputs = [USEquityPricing.close, USEquityPricing.high, USEquityPricing.low]
window_length = 30
def compute(self, today, assets, out, close, high, low):
lb = self.window_length
e_r = np.zeros(len(assets), dtype=np.float64)
a=np.array(([high[1:(lb):1]-low[1:(lb):1],abs(high[1:(lb):1]-close[0:(lb-1):1]),abs(low[1:(lb):1]-close[0:(lb-1):1])]))
b=a.T.max(axis=1)
c=b.sum(axis=1)
e_r=abs(close[-1]-close[0]) /c
out[:] = e_r