Hello,
I have a problem with applying custom factor which should select stocks with minimum 5% of mean intraday price range over some period. Below part of code:
class IntraDayMeanDifference(CustomFactor):
inputs = [USEquityPricing.high, USEquityPricing.low, USEquityPricing.close]
window_length = 20
def compute(self, today, asset_ids, out, high, low, close):
diff = (high - low)/close*100
diff = np.sort(diff) #sort results
diff = diff[4:-2] #filter some border values
out[:] = np.mean(diff, axis=0)
The rest please find in attached backtest.
The problem is that based on my custom factor, pipeline returns stocks like Google or Paypal, which we know that are not so volatile.
2016-07-05 PRINT dollar_volume high_low_diff latest_close
Equity(45971 [AAL]) 3.535842e+08 5.198106 29.33
Equity(45993 [HLT]) 2.024517e+08 5.217377 22.88
Equity(46631 [GOOG]) 8.382134e+08 5.683298 699.28
Equity(46979 [JD]) 2.828034e+08 6.038528 21.30
Equity(47415 [SYF]) 2.765042e+08 6.650303 25.33
Equity(47430 [MBLY]) 2.106279e+08 6.687589 47.12
Equity(47740 [BABA]) 6.974509e+08 7.033304 79.67
Equity(49073 [LABU]) 1.510457e+08 11.622539 30.88
Equity(49229 [KHC]) 2.018926e+08 15.681655 88.22
Equity(49242 [PYPL]) 3.059107e+08 16.513557 36.35
On the other hand, research platform gives rational results when calculating this intraday price range.
Any help/explanation will be appreciated, thanks.