Beginner Python Stock Screener

Beginner Python Stock Screener

Questions : Beginner Python Stock Screener

641

I try to build a simply stock screener. The in4codes_pandas screener should download the volume and avg. in4codes_pandas volume and should give me all stocks with in4codes_pandas the condition volume > avg. volume.

The Problem is, that something went wrong in4codes_pandas and i don’t know how to fix the code. Its a in4codes_pandas overall problem in the code and i hope i can in4codes_pandas get some help. Often i get the message, that in4codes_pandas the data is empty. But i think there is in4codes_pandas something wrong with the tables and the in4codes_pandas conditions…

The first for loop gives me this and this is in4codes_pandas good, i think there is no mistake in the in4codes_pandas code

Ticker volume avg. volume aapl 31 20 ayx 20 32 nflx 25 28 

The second for loop is to check my condition in4codes_pandas ( volume > avg. volume)

but it gives me the following output:

 ticker1 ... Stock 0 NaN ... ticker1 1 NaN ... Volume_1 2 NaN ... Average_Volume [3 rows x 4 columns] Process finished with exit code 0 

normaly only apple fullfills the conditions in4codes_pandas and it must look like:

Stock volume avg. volume aapl 31 20 

Thats my code:

from yahoo_fin.stock_info import get_analysts_info, get_stats, get_live_price, get_quote_table import pandas as pd import ssl ssl._create_default_https_context = ssl._create_unverified_context tickers = ['aapl', 'ayx' , 'nflx'] exportList = pd.DataFrame(columns = ['ticker1', 'Volume_1', 'Average_Volume']) for ticker in tickers: df = get_stats(ticker) df['ticker'] = ticker df = df.pivot(index = 'ticker', columns = 'Attribute', values = 'Value') df['Volume_1'] = get_quote_table(ticker)['Volume'] df['Average_Volume'] = get_quote_table(ticker)['Avg. Volume'] df = df[['Volume_1', 'Average_Volume']] df = df.reset_index() df.columns = ('ticker', 'Volume_1', 'Average_Volume') rs_df = pd.DataFrame (columns = ['ticker1', 'Volume_1', 'Average_Volume']) for stock in rs_df: Volume_1 = df["Volume_1"] Average_Volume = df["Average_Volume"] if float(Volume_1) < float(Average_Volume): exportList = exportList.append({'Stock': stock, "Volume_1": Volume_1, "Average_Volume": Average_Volume}, ignore_index=True) print('n', exportList) 

Total Answers 0