def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) filters = ['fa_eps5years_pos','fa_epsqoq_o20','fa_epsyoy_o25','fa_epsyoy1_o15','fa_estltgrowth_pos','fa_roe_o10','sh_instown_o10','ta_highlow52w_a50h','ta_rsi_nos50'] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName,get_screener_name()) #dump_to_csv('screenerOutput')
def test_get_ticker_details_sequential_requests(self): stocks = Screener(filters=[ 'sh_curvol_o300', 'ta_highlow52w_b0to10h', 'ind_stocksonly', 'sh_outstanding_o1000' ]) ticker_details = stocks.get_ticker_details() count = 0 for _ in ticker_details: count += 1 assert len(stocks) == count == len(ticker_details)
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) filters = [ 'fa_debteq_u0.5', 'fa_epsqoq_o25', 'fa_roe_o15', 'fa_salesqoq_o20', 'sh_avgvol_o200', 'sh_instown_o60', 'sh_price_o5', 'sh_short_u5' ] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName, get_screener_name())
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) filters = ['geo_usa','ta_change_u','ta_highlow20d_nh','ta_highlow50d_nh','ta_highlow52w_nh','ta_perf_dup'] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName,get_screener_name()) #dump_to_csv('screenerOutput')
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) filters = ['sh_avgvol_o1000', 'ta_pattern_channelup', 'ta_perf_1wdown' ] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName, get_screener_name()) #dump_to_csv('screenerOutput')
def top_N_biggest(self, N, table=None, stock_list=None): filters = ['geo_usa', 'sh_curvol_o2000'] if stock_list is None: stock_list = Screener(filters=filters, order='-marketcap', rows=N, table=table) else: stock_list = Screener(tickers=stock_list, order='-marketcap', rows=N, table=table) self.log(stock_list) return stock_list
def top_N_volatility(self, N, table=None, stock_list=None): filters = ['geo_usa', 'cap_largeover', 'sh_avgvol_o1000'] if stock_list is None: stock_list = Screener(filters=filters, order='-volatility1w', rows=N, table=table) else: stock_list = Screener(tickers=stock_list, order='-volatility1w', rows=N, table=table) self.log(stock_list) return stock_list
def __init__(self, update=True): filters = [ 'exch_Any', 'idx_Any', 'geo_usa', 'sh_price_u50', 'avgvol_o50' ] print("Filtering stocks..") stock_list = Screener(filters=filters, order='ticker') stock_list.to_csv('data/stocks.csv') #print(stock_list) with open('data/stocks.csv') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') for row in csv_reader: global exportList exportList.append(row[1])
def test_get_ticker_details_sequential_requests(self): """ Tests that `get_ticker_details` method returns correct number of ticker details. """ stocks = Screener(filters=[ "sh_curvol_o300", "ta_highlow52w_b0to10h", "ind_stocksonly", "sh_outstanding_o1000", ]) ticker_details = stocks.get_ticker_details() count = 0 for _ in ticker_details: count += 1 assert len(stocks) == count == len(ticker_details)
def GrabStockList(): filters = [ "an_recom_holdbetter,cap_midunder,geo_usa,sh_avgvol_o300,sh_curvol_o300,sh_price_5to50,ta_highlow52w_b5h,ta_perf_13wup,ta_perf2_ytdup,ta_rsi_nob60,ta_sma20_pca,ta_sma200_pa,ta_sma50_pa" ] stock_list = Screener(filters=filters) for stock in stock_list: print(stock["Ticker"])
def DailySectorsScreen(): sectorsTktList = [ 'IWM', 'XLF', 'EEM', 'XLE', 'XLK', 'XLV', 'IYT', 'XLU', 'XLI', 'XLY', 'IYR', 'XLP', 'XLB', 'TLT', 'GLD', 'UUP', 'RTH', 'IYZ', 'SMH', 'DBC', 'USO' ] return Screener(tickers=sectorsTktList, table='Overview', order='-change')
def etfDailyData(filePrefix, outputDir): src = 'screener_results.csv' filtro = ['ind_exchangetradedfund'] tables_list = ['Overview', 'Performance', 'Technical'] desc_change = '-change' os.chdir(outputDir) dirpath = os.getcwd() print("current directory is : " + dirpath) for tabla in tables_list: stk_list = Screener(filters=filtro, order=desc_change, table=tabla) stk_list.to_csv(src) dst = filePrefix + '_etf_' + tabla.lower() + '.csv' os.rename(src, dst) return 0
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) #http://freetraderchat.com/blog/top-5-finviz-scans/ #https://finviz.com/screener.ashx?v=111&f=cap_midunder,fa_epsqoq_o5,fa_salesqoq_o5,sh_instown_o10,sh_price_u5,ta_averagetruerange_o0.25,ta_sma20_pa,ta_sma200_pa,ta_sma50_pa&ft=4 filters = ['cap_midunder','fa_epsqoq_o5','fa_salesqoq_o5','sh_instown_o10','sh_price_u5','ta_averagetruerange_o0.25','ta_sma20_pa','ta_sma200_pa','ta_sma50_pa'] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName,get_screener_name()) #dump_to_csv('screenerOutput')
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) filters = [ 'sh_curvol_o200', 'sh_price_u7', 'sh_relvol_o1.5', 'sh_short_low', 'ta_rsi_nos50', 'ta_sma20_pa', 'ta_sma200_pa', 'ta_sma50_pa' ] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName, get_screener_name()) #dump_to_csv('screenerOutput')
def top_N_bouce_back(self, N, table=None, stock_list=None): filters = [ 'geo_usa', 'cap_largeover', 'sh_avgvol_o1000', 'ta_highlow52w_b30h' ] if stock_list is None: stock_list = Screener(filters=filters, order='change', rows=N, table=table) else: stock_list = Screener(tickers=stock_list, order='change', rows=N, table=table) self.log(stock_list) return stock_list
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) # https://www.intelligenttrendfollower.com/how-to-find-trend-following-stock-ideas-on-finviz/ #https://finviz.com/screener.ashx?v=111&f=ta_pattern_channelup2&ft=3?a=128563647 filters = ['ta_pattern_channelup2'] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName,get_screener_name()) #dump_to_csv('screenerOutput')
def Top_N_SMA20_crossing_SMA50(self, N, table=None, stock_list=None): filters = [ 'geo_usa', 'cap_midover', 'sh_avgvol_o2000', 'ta_sma20_cross50' ] if stock_list is None: stock_list = Screener(filters=filters, order='sma20', rows=N, table=table) else: stock_list = Screener(tickers=stock_list, order='sma20', rows=N, table=table) self.log(stock_list) return stock_list
def stkDailyDataT(filePrefix, outputDir): src = 'screener_results.csv' filtro = ['ind_stocksonly'] tables_list = ['Technical'] desc_change = '-change' os.chdir(outputDir) dirpath = os.getcwd() print("current directory is : " + dirpath) for tabla in tables_list: print("tabla stkDailyData " + tabla) stk_list = Screener(filters=filtro, order=desc_change, table=tabla) stk_list.to_csv(src) dst = filePrefix + '_stk_t_' + tabla.lower() + '.csv' os.rename(src, dst) return 0
def top_N_oversold(self, N, table=None, stock_list=None): filters = ['geo_usa', 'cap_largeover', 'sh_curvol_o2000'] if stock_list is None: stock_list = Screener(filters=filters, order='rsi', rows=N, table=table) else: print("from ticker pool") #stock_list = Screener(tickers=stock_list, filters=['sh_curvol_o2000'], order='rsi', rows=N, table=table) stock_list = Screener(tickers=stock_list, filters=['sh_curvol_o2000'], order='-rsi', rows=N, table=table) self.log(stock_list) return stock_list
def FindTopStocks(): print("Searching Stocks...") stocks = [] for pattern in patterns: stocks_ = Screener(signal=pattern) for stock in stocks_: stocks.append(stock['Ticker']) return stocks
def YTDSectorsScreen(): sectorsTktList = [ 'IWM', 'XLF', 'EEM', 'XLE', 'XLK', 'XLV', 'IYT', 'XLU', 'XLI', 'XLY', 'IYR', 'XLP', 'XLB', 'TLT', 'GLD', 'UUP', 'RTH', 'IYZ', 'SMH', 'DBC', 'USO' ] return Screener(tickers=sectorsTktList, table='Performance', order='-perfytd')
def stockScreener(shortable, min_s_float, max_s_float, minOSS, maxOSS, PriceLimit): filters = ['exch_nasd'] stock_list = Screener(filters=filters, order='price') AcceptedStocks = [] print(len(stock_list)) for stock in stock_list: #print(stock['Ticker'], stock['Price']) symbol = stock['Ticker'] sData = GetStockData(symbol) price = float(sData['Price']) if (price > PriceLimit): break if ('-' not in sData['Insider Own']): if (float(sData['Insider Own'].replace('%', '')) < 10): continue stock_shortable = sData['Shortable'] == 'Yes' OutStandingShares = sData['Shs Outstand'] Week52Range = sData['52W Range'] L52 = float(Week52Range[0:Week52Range.index('-') - 1]) H52 = float(Week52Range[Week52Range.index('-') + 1::]) if (H52 > price and 100 * (price / H52) >= 15): continue if (price < L52): continue if OutStandingShares[-1] != 'M': continue else: OutStandingShares = float( OutStandingShares[0:len(OutStandingShares) - 1]) floatVal = sData['Shs Float'] if (floatVal == '-'): continue else: try: floatVal = float(floatVal[0:len(floatVal) - 1]) if (floatVal > 5.0): continue print("Good Float!") except ValueError: print("Float Val Error" + floatVal) shortFloat = 0.0 try: shortFloat = float(sData['Short Float'].replace('%', '')) except ValueError: continue if (stock_shortable == shortable and shortFloat >= min_s_float and shortFloat <= max_s_float and minOSS <= OutStandingShares and maxOSS >= OutStandingShares): AcceptedStocks.append( stockData(symbol, shortFloat, OutStandingShares, floatVal)) print(symbol + " Meets the requirements") else: print(symbol + " Does not meet requirements!") return AcceptedStocks
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) #http://freetraderchat.com/blog/top-5-finviz-scans/ #https://finviz.com/screener.ashx?v=111&f=sh_curvol_o200,sh_price_u10,ta_change_u,ta_changeopen_u,ta_perf_dup,ta_perf2_d15o&ft=4 filters = [ 'sh_curvol_o200', 'sh_price_u10', 'ta_change_u', 'ta_changeopen_u', 'ta_perf_dup', 'ta_perf2_d15o' ] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName, get_screener_name()) #dump_to_csv('screenerOutput')
def get_current_dataframe(): filters = [ 'fa_debteq_u0.5', 'fa_epsqoq_o25', 'fa_roe_o15', 'fa_salesqoq_o20', 'sh_avgvol_o200', 'sh_instown_o60', 'sh_price_o5', 'sh_short_u5' ] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print(type(stock_list)) #dump_to_csv('screenerOutput')
def compilepimary(): dictionary_ticker_mc = {} filters = ['cap_midover','geo_usa'] stock_list = Screener(filters=filters, table='Valuation', order='market cap') # Get the performance table and sort it by price ascending for stock in stock_list: dictionary_ticker_mc[stock['Ticker']] = stock['Market Cap'] remove = [k for k,v in dictionary_ticker_mc.items() if v == '-'] for k in remove: del dictionary_ticker_mc[k] return dictionary_ticker_mc
def test_get_screener_data_sequential_requests(self): stocks = Screener(filters=[ 'sh_curvol_o300', 'ta_highlow52w_b0to10h', 'ind_stocksonly' ]) count = 0 for _ in stocks: count += 1 assert len(stocks) == count
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) #http://freetraderchat.com/blog/top-5-finviz-scans/ #https://finviz.com/screener.ashx?v=111&f=sh_avgvol_o200,sh_price_u10,ta_averagetruerange_o0.25,ta_change_d,ta_pattern_horizontal,ta_perf_ddown,ta_perf2_d5u&ft=4 filters = [ 'sh_avgvol_o200', 'sh_price_u10', 'ta_averagetruerange_o0.25', 'ta_change_d', 'ta_pattern_horizontal', 'ta_perf_ddown', 'ta_perf2_d5u' ] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName, get_screener_name()) #dump_to_csv('screenerOutput')
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) #https://www.reddit.com/r/CANSLIM/comments/6rfupr/finviz_screeners_settings/ #https://finviz.com/screener.ashx?v=111&f=cap_small,fa_eps5years_o20,fa_epsqoq_o20,fa_epsyoy_o20,fa_sales5years_o20,fa_salesqoq_o20,sh_curvol_o200&ft=4 filters = [ 'cap_small', 'fa_eps5years_o20', 'fa_epsqoq_o20', 'fa_epsyoy_o20', 'fa_sales5years_o20', 'fa_salesqoq_o20', 'sh_curvol_o200' ] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName, get_screener_name()) #dump_to_csv('screenerOutput')
def dump_to_csv(dirName): if not os.path.exists(dirName): os.makedirs(dirName) #http://www.winninginvesting.com/small_cap_screen.htm #https://finviz.com/screener.ashx?v=111&f=cap_small,fa_epsyoy_o15,fa_epsyoy1_o15,fa_estltgrowth_o15,fa_peg_u1,fa_roe_pos,geo_usa,sh_avgvol_o500,sh_instown_o40&ft=4 filters = [ 'cap_small', 'fa_epsyoy_o15', 'fa_epsyoy1_o15', 'fa_estltgrowth_o15', 'fa_peg_u1', 'fa_roe_pos', 'geo_usa', 'sh_avgvol_o500', 'sh_instown_o40' ] # Shows companies in NASDAQ which are in the S&P500 stock_list = Screener(filters=filters, order='ticker') print((stock_list)) stock_list.to_csv(dirName, get_screener_name()) #dump_to_csv('screenerOutput')
def test_get_screener_data_sequential_requests(self): """ Tests that basic Screener example returns correct number of stocks. """ stock_list = Screener(filters=[ "sh_curvol_o300", "ta_highlow52w_b0to10h", "ind_stocksonly" ]) count = 0 for _ in stock_list: count += 1 assert len(stock_list) == count