Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Custom Factor

How do i make the following into a custom factor so that i can implement in the pipeline? Thanks

def slope(ts):
x = np.arange(len(ts))
log_ts = np.log(ts)
slope, intercept, r_value, p_value, std_err = stats.linregress(x, log_ts)
annualized_slope = (np.power(np.exp(slope), 250) - 1) * 100
return (annualized_slope * (r_value ** 2))