This gets a list of stock symbols representing the Q500US.
import numpy
import datetime
from quantopian.pipeline import CustomFactor, Pipeline
from quantopian.research import run_pipeline
from quantopian.pipeline.filters import QTradableStocksUS
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.pipeline.data import Fundamentals
base_universe = QTradableStocksUS()
start = datetime.date.today()
f = Fundamentals
class change(CustomFactor):
inputs = [USEquityPricing.close]
def compute(self, today, assets, out, close):
out[:] = close[0]
def make_pipeline():
time1 = ((change(window_length=1) / change(window_length=10)) - 1) * 100
time2 = ((change(window_length=1) / change(window_length=20)) - 1) * 100
time3 = ((change(window_length=1) / change(window_length=100)) - 1) * 100
time4 = ((change(window_length=1) / change(window_length=200)) - 1) * 100
my_symbol = Fundamentals.symbol.latest
my_desc = Fundamentals.standard_name.latest
##### https://www.quantopian.com/help/fundamentals
##### https://www.quantopian.com/posts/trading-all-stocks-on-quantopian
##### Financial & accounting valuation of assets vs liabilities
fh = Fundamentals.financial_health_grade.latest
##### The trend in RPS over the past 5 years
gg = Fundamentals.growth_grade.latest
##### Evaluates the returns on shareholder equity, or ROE, over the past 5 years
pg = Fundamentals.profitability_grade.latest
##### Growth indicator of a stock’s EPS, book value, revenues, and cash flow
gs = Fundamentals.growth_score.latest
##### High score is assigned to stocks that are priced low in comparison to strong EPS, book value, revenues, cash flow, and dividends
vs = Fundamentals.value_score.latest
return Pipeline(
columns={
'T Desc' : my_desc,
'Financial Health' : fh,
'Growth Grade' : gg,
'Profitability Grade' : pg,
'Growth Score' : gs,
'Value Score' : vs,
'Dma 10' : time1,
'Dma 20' : time2,
'Dma 100' : time3,
'Dma 200' : time4
},
)
results = run_pipeline(make_pipeline(), start, start).dropna()
#results = results.query('Growth Grade' == "A")
results = results[['T Desc','Value Score','Growth Score','Financial Health','Growth Grade','Profitability Grade','Dma 10','Dma 20','Dma 100','Dma 200']]
results.sort_values('Value Score',ascending=False)