I'm currently looking into a relationship between short-term momentum and high turnover. I have developed my momentum custom factor and attempting to develop my turnover factor as a screen but, I'm currently having issues with forming a proper output.
Here is what i got:
from quantopian.pipeline import Pipeline, CustomFactor from quantopian.pipeline.data.morningstar import Fundamentals from quantopian.pipeline.data import USEquityPricing from quantopian.pipeline.factors import Returns from quantopian.research import run_pipeline from quantopian.pipeline.filters import QTradableStocksUS import numpy as np class ShortMom(CustomFactor): inputs = [USEquityPricing.close] window_length = 21 # to examine short-term monthy mom in relation to turnvoer def compute(self,today,assets,out,close): out[:] = (close[self.window_length-1] - close)/close mtm_factor = ShortMom() class TO(CustomFactor): inputs = [USEquityPricing.volume, Fundamentals.shares_outstanding] window_length = 21 # monthly turnover is the one we need def compute(self,today,assets_ids, out, volume, shares): out[:] = (volume / shares) TO_High = TO() TO_High_Filter = (TO_High.percentile_between(75,100, mask=(TO_High > 0)))
I know I have done something wrong with attempting to calculate the turnover but do not know how to fix it. If anyone can please help, it will be greatly appreciated!