def revenue_y_gt_accounts_receive_3_years(): return expr.Or( expr.And( expr.Gt(expr.Get('f_revenue_y.y2y'), expr.Get('f_accounts_receiv_y.y2y')), expr.Gt( expr.Before(expr.Get('f_revenue_y.y2y'), past_year=1), expr.Before(expr.Get('f_accounts_receiv_y.y2y'), past_year=1))), expr.And( expr.Gt( expr.Before(expr.Get('f_revenue_y.y2y'), past_year=1), expr.Before(expr.Get('f_accounts_receiv_y.y2y'), past_year=1)), expr.Gt( expr.Before(expr.Get('f_revenue_y.y2y'), past_year=2), expr.Before(expr.Get('f_accounts_receiv_y.y2y'), past_year=2))), expr.And( expr.Gt( expr.Before(expr.Get('f_revenue_y.y2y'), past_year=2), expr.Before(expr.Get('f_accounts_receiv_y.y2y'), past_year=2)), expr.Gt( expr.Before(expr.Get('f_revenue_y.y2y'), past_year=3), expr.Before(expr.Get('f_accounts_receiv_y.y2y'), past_year=3))))
def current_y_gt_1_3_years(): return expr.Or( expr.And( expr.Gt(expr.Get('f_current_y.r'), expr.Value(1)), expr.Gt(expr.Before(expr.Get('f_current_y.r'), past_year=1), expr.Value(1))), expr.And( expr.Gt(expr.Before(expr.Get('f_current_y.r'), past_year=1), expr.Value(1)), expr.Gt(expr.Before(expr.Get('f_current_y.r'), past_year=2), expr.Value(1))), expr.And( expr.Gt(expr.Before(expr.Get('f_current_y.r'), past_year=2), expr.Value(1)), expr.Gt(expr.Before(expr.Get('f_current_y.r'), past_year=3), expr.Value(1))))
def revenue_y_gt_inventoires_3_years(): return expr.Or( expr.And( expr.Gt(expr.Get('f_revenue_y.y2y'), expr.Get('f_inventories_y.y2y')), expr.Gt(expr.Before(expr.Get('f_revenue_y.y2y'), past_year=1), expr.Before(expr.Get('f_inventories_y.y2y'), past_year=1))), expr.And( expr.Gt(expr.Before(expr.Get('f_revenue_y.y2y'), past_year=1), expr.Before(expr.Get('f_inventories_y.y2y'), past_year=1)), expr.Gt(expr.Before(expr.Get('f_revenue_y.y2y'), past_year=2), expr.Before(expr.Get('f_inventories_y.y2y'), past_year=2))), expr.And( expr.Gt(expr.Before(expr.Get('f_revenue_y.y2y'), past_year=2), expr.Before(expr.Get('f_inventories_y.y2y'), past_year=2)), expr.Gt(expr.Before(expr.Get('f_revenue_y.y2y'), past_year=3), expr.Before(expr.Get('f_inventories_y.y2y'), past_year=3))))
def horseFilter(): return expr.Name( 'f:horse_filter', expr.And( expr.Name('f:roe_ge_15_pct_last_7_year', roe_ge_15_pct_last_7_year()), expr.Name('f:revenue_r_gt_0', revenue_r_gt_0()), expr.Name('f:income_attr_p_r_gt_0', income_attr_p_r_gt_0()), expr.Name('f:revenue_y_gt_accounts_receive_3_years', revenue_y_gt_accounts_receive_3_years()), expr.Name('f:revenue_y_gt_inventoires_3_years', revenue_y_gt_inventoires_3_years()), expr.Name('f:current_y_gt_1_3_years', current_y_gt_1_3_years())))
def run(y, q): rm = expr.Range(expr.Before(expr.Get('f_roe_y'), past_year=1), year_count=6) nm = self.roe_ge_15_pct_now() v = rm.eval(self.stock, y, 4) v2 = expr.Ge(rm, expr.Value(0.15)).eval(self.stock, y, 4) print('last 6 years', v, v2) v3 = nm.eval(self.stock, y, q) print('current', v3, expr.Get('f_roe').eval(self.stock, y, q)) v4 = expr.And(expr.Ge(rm, expr.Value(0.15)), nm).eval(self.stock, y, q) print('last 7 years', v4)
def gooseFilter(): return expr.And(roe_ge_15_pct_last_3_years())
def income_attr_p_r_gt_0(): return expr.And( expr.Gt(last_year_f_income_attr_p_y_r_y2y(), expr.Value(0)), expr.Gt(last_quarter_f_income_attr_p_q_r_y2y(), expr.Value(0)))
def revenue_r_gt_0(): return expr.And(expr.Gt(last_year_f_revenue_y_r_y2y(), expr.Value(0)), expr.Gt(last_quarter_f_revenue_q_r_y2y(), expr.Value(0)))
def roe_ge_15_pct_last_7_year(): return expr.And(roe_ge_15_pct_before_6_years(), roe_ge_15_pct_now())