Hi Nathan,
Thank you for the reply! I've been looking at the Pipeline documentation and played around with the coding for a bit but can't seem to get output I want. I'm confused as to how to use the USEquityPricing.close.latest and comparing to which 2 thresholds. Here is my code so far:
from quantopian.pipeline import Pipeline
from quantopian.algorithm import attach_pipeline, pipeline_output
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.pipeline.factors import AverageDollarVolume
def initialize(context):
pipe = Pipeline()
attach_pipeline(pipe, 'my_pipeline')
# Create a dollar volume factor.
dollar_volume = AverageDollarVolume(window_length=1)
# Pick the top 1% of stocks ranked by dollar volume.
high_dollar_volume = dollar_volume.percentile_between(99, 100)
pipe.add(high_dollar_volume, 'high_dollar_volume')
# Construct a Filter.
prices_under_5 = (high_dollar_volume < 5)
pipe.set_screen(high_dollar_volume & prices_under_5)
def before_trading_start(context, data):
output = pipeline_output('my_pipeline')
# These are the securities that we are interested in trading each day.
context.my_universe = output.sort('high_dollar_volume', ascending=False).iloc[:5]
# Define a universe with the results of a Pipeline.
context.assets = context.my_universe.index
def handle_data(context, data):
log.info('\n'+str(context.my_universe.head()))
Please let me know what I've used wrongly and what correction I need to make. Or if there are video resources that are up to date that I can watch and further my learning. And again thank you for your help!!