Hello all,
So it seems that i was able to solve this myself.
The solution is not really optimal, but it works.
It does calculations on the whole universe (whole pipeline), but then it filters the results to only look at certains SIDs and take the top X of those, ranked by a calculated factor.
This filtering is done daily in the before_trading_start procedure.
#ALL results of the pipeline are put in context.output
context.output = pipeline_output('ranked_stocks').fillna(0)
context.etf_list= [sid(19662), # XLY Consumer Discrectionary SPDR Fund
sid(19656), # XLF Financial SPDR Fund
sid(19658), # XLK Technology SPDR Fund
sid(19655), # XLE Energy SPDR Fund
sid(19661), # XLV Health Care SPRD Fund
sid(19657), # XLI Industrial SPDR Fund
sid(19659), # XLP Consumer Staples SPDR Fund
sid(19654), # XLB Materials SPDR Fund
sid(19660),
sid(8554)] # XLU Utilities SPRD Fund
#Filter only the stocks we are interested in
x = context.output[context.output.index.isin(context.etf_list)]
#sort according to a calculated factor (combo_rank in this case) and get top 10
context.stock_list = x.sort(['combo_rank'], ascending=True).iloc[:10]
#update_universe(context.stock_list.index) - depreciated, use the following instead:
context.assets = [context.stock_list.index]