Stock Screener in Python

NeuralNine · Beginner ·💻 AI-Assisted Coding ·5y ago

Key Takeaways

The video demonstrates how to build a stock screener in Python using libraries such as pandas and yfinance to load financial data from Yahoo Finance API, calculate stock performance, and filter out best performers based on return compared to S&P 500. It also covers data analysis, data visualization, and algorithmic trading concepts.

Full Transcript

[Music] what is going on guys welcome back in today's video we're going to build a simple stock screener in python so let's get right into it all right guys so what is a stock screener now a stock screener is basically just a tool that allows you to look through a bunch of different stocks and find the ones that match your criteria that you determine in advance so let's say you look through the s p 500 there you have 500 companies and you want to find those that match your criteria for example you might say i want to have a company uh or i only want to see companies that have a p e ratio of less than 30 for example or you want to have a pack ratio of less than two or you want to have a moving average uh over the last 30 days of whatever so it's important that you know what your criteria is and the stock screener can then help you to just look through a bunch of different stocks automatically you don't have to go to each individual company look at the values calculate the values yourself you can just do it with the tool and this is what we're going to build today in python and for this we're going to start with uh or by installing a couple of libraries so we're going to open up cmd or your favorite terminal of choice by the way let me just reposition my camera before i forget it so scaling it down putting it to the upper right corner uh there you go so the library we're going to need today is going to be first of all panda so pip install pandas i'm not going to do that because i already have it we're going to also install pandas data reader so pandas data reader like that pandas data reader and last but not least yahoo fin which is for yahoo finance and this is what we're going to use in order to get some more stock information so this is how we do it um and we're going to import pandas data reader as web we're going to import pandas spd we're going to import we're actually going to save from yahoo fin import stock info s s i and then import date time as dt so our goal is going to be to just go through the s p 500 companies and find the ones that match our criteria now what the criteria is we're just going to make something up we're not going to use anything that is uh really meaningful here we're just going to set some certain things that we want to have and then we're going to find the companies that fulfill this uh so first of all we're going to have to get all the ticker symbols of the s p 500 so um for those of you who have watched already a bunch of the stock tutorials on this channel you know that you we always use sorry we always use uh the pandas data reader to load the data from the yahoo finance api for specific companies and we do that by specifying um the ticker symbols of the individual companies now the s p 500 has 500 companies and we need to ticker symbols of those and how do we get them we just say tickers equals s i dot tickers sp 500 like that so now we have the tickers now what we need to do is we need to specify a time frame that we're looking at so what we're going to do here is we're going to compare the performance of individual stocks um to the performance of the s p 500 as a whole so we're going to look at which stocks beat the market which stocks are under performance so on and then based on that comparison we're going to make a decision so we're going to say start equals and we can say dt.datetime and you can specify a date if you want to so you can say for example 2020 first of january or we're just going to look at uh the last year or the last 365 days so dt date time now um and what was it minus dt time delta days equals 365. so basically from now minus 365 days is the start and end is just going to be dt daytime dot now there you go um so again as i said if you want to have a specific date you can just say dt date time 2020 1 1 for example if you want to um now we're going to first load the s p 500 data frame so we're going to load the information about the s p 500 and then we're going to compare it to the individual stock so first of all we're going to say sp500df is going to be web data reader and the symbol is uh this symbol here i'm not sure what it's called hat uh at least in mathematics it's called hat then uh gspc this is the ticker symbol of the s p 500 atf we're going to load it from the yahoo finance api from start to end there you go and now we're going to say s p 500 data frame and we're going to calculate the percentage uh change so we want to know okay the closing value the adjusted closing value how much does how much does it change from day to day so what we're going to do is we're going to say s p 500 d f p c t change is going to be s p 500 data frame adjusted close dot percentage percentage change so this is already a function that is part of pandas we don't need to implement it or actually a method another function and what we want to know in the end the final thing that we are actually interested in is the return so over that time frame what was the actual return and we're going to get that by saying s p 500 return equals s p 500 data frame percentage change plus one and we're going to have the cumulative product so hume prod and we're going to pick the last value because we're interested in the final return so that is the return that is how we calculate it and now what we're going to do is we're going to do the same thing that we did here for all the individual stocks and then we're going to compare them to the actual uh returns of the s p 500 etf so we're going to say return list is an empty list first and we're going to craft the final data frame the final data frame is what we're going to look at in order to make buying decisions we're going to initialize it here but we're going to use it later on so i'm just going to define it uh we're going to say final df is going to be pd data frame and the columns are what is important here so we're only going to define the columns here um and what things are we interested in you can decide for yourself uh you don't have to use the strategy quote-unquote that i'm using in this video by the way because i forgot to to to mention it this video is not financial advice don't listen to me when it comes to financial advice i'm a programmer i'm a computer scientist i'm teaching you programming don't listen to me in any way when it comes to uh stock investing crypto investing anything i'm not responsible for any losses that you make also not for any gains that you make so don't listen to me when it comes to financial advice it's just an important disclaimer here that i always need to make on youtube um so what we're interested here is uh the ticker column you want to have a ticker symbol we want to have the latest price latest price we want to have a score value that we're going to define uh in a second what the score means i'm just uh adding it here so score basically is going to be how it compares to the s p 500 returns then we're going to have the p e ratio we're going to have the peg ratio which is uh p e and growth so price to earnings ratio and price earnings growth ratio uh then we're going to have the moving average sma for 150 days we're going to have the moving average for 200 days and we're going to have uh 52 week low and 52 week hi again you can just pick two of those if you want you can add 100 more values here those are just the columns that you want to make your decision with so if you don't care about the moving averages if you don't care about the peg ratio use something else you know maybe you only care about p e ratio score and 52 week low nothing else so depending on what you're interested in when you're screening for stocks this is what you put into those columns here in this video i'm going to use those just because i think they're interesting uh but i wouldn't say that this is necessarily what you should look at when you make investment decisions so this is more about programming here all right so now we have that and we're going to save for ticker and tickers so for all tickers that we have from the s p 500 we're going to say a data frame that's just going to be a temporary data frame is going to be web data reader and we're basically going to load the information for the ticker from the yahoo finance api the same way we did it above start to end so the same thing that we did here with the s p 500 as a whole we're now doing for all the individual companies uh so we say um df to csv as well by the way this is not necessarily something that you have to do you can also just keep it in memory all the time but later on it's just easier to have this csv file that you can just open if you want to do something with it so i like to save the stuff into a csv file and we're going to call this stock data slash ticker dot csv as an f string formatted and then we're going to calculate the percentage change here as well so pct change is going to be adjusted close dot percentage change and the return is going to be again the cumulative product so stock return is going to be data frame percentage percentage change plus one um dot cumulative product last element there you go so that is it and now the only thing we need to do is we need to calculate the returns compared to the s p 500 so we're going to say returns compared is going to be rounded the stock return divided by the s p 500 return rounded to two decimal places and then we're going to return to add this thing to the return list which is up here so we're going to have all the returns up here in this list so return list append returns compared so that is how we basically do that all right so in the next step what we're going to do is we're going to filter out the best performance now you don't need to do that this is just one decision that i make in this video to make a decision you can also say i want to have the worst performance or i don't care about the performance compared to the s p 500 i care about moving averages and i care about p e ratios and so on if that is the case of course you can skip that step but i'm going to do it here just to show you how you would do something like that so we want to know what are the best performers here and how do we do that we say best performers equals and now we create a new data frame so we say data frame and i'll create a list of zip now if you don't know what the zip function does i have a video on this channel i don't want to go into too much details here uh because this video is already going to be a little bit longer than usual so i'm not going to explain the zip function in detail here but i have in my advanced python tutorial series or i think it was in python tips and tricks one of the two i have a video on the zip function so if you want to know what it does just look into it we're going to zip the tickers and the return list um and then we're going to say the columns are just going to be ticker and returns compared [Music] and now what we're going to do is we're going to say best performance score it's going to be best performance returns compared and we're going to use the rank method the rank method basically does exactly what we want we want to have the best uh performance so we want to know okay um when we compare the returns which returns compared to the s p 500 rank the best so we're going to see rank we're going to say percentage equals true because we don't want to have absolute values you want to have percentage and we're going to multiply this with 100 because we want to have uh the actual percentage values here and now we're going to say best performers we're going to cut out the rest so we're going to only leave the best performance is going to be best performers and here we now have to specify the criteria and the criteria is going to be that the best performance score must be larger or equal to the best performance score dot quantile and here you can specify uh what you're interested in the top thirty percent the top twenty percent the top um ten percent the top fifty percent maybe only so the quantile basically means uh from that point on everything um or what would you say if you pick let me let me put it uh let me explain it with an example if you pick the quantile 0.8 for example zero point eight that means that you're picking the top twenty percent because you're going to the uh to the eighty percent uh quantile and you're saying okay everything below that is worse and i wanna have only the top twenty percent uh this is how this method works here so we're going to pick 70 so we're going to actually pick the top 30 percent those are going to be the best performance the top 30 percent uh when you compare their returns to the s p 500 returns which does not necessarily say that this is a good decision because after all maybe the worst performers are going to have a better performance in the future whereas the best performers are going to go downhill so you don't know but this is just how you would do it if you choose to to pick that investment strategy and now what we're going to do is we're going to actually go ahead and calculate all the criteria for those best performance so if we don't have a stock in the best performance we're not even going to consider it but those best performers we're going to apply to them uh the criteria that we're interested in so we're going to say for ticker in best performance uh but not in best performance in general but in best performers ticker so for those tickers we're going to load the csv file so we're not going to again uh use the yahoo finance api up here we're going to use the csv files that we have created by using this dataframe.2csv and we're going to say try so that if we get an exception we're not going to crash the script so try accept i'm going to use pass as a placeholder here and we're going to say pry not pry try data frame equals pandas.read csv and we're going to read stock data was it stock data stock data yes slash ticker dot csv and index column we're going to set to zero here so this is going to be the data frame that we load from the csv file and now we're going to calculate the moving averages so we're going to say moving averages uh and we were interested i think in 150 and 200 so we're going to say moving averages is just going to be 150 and 200 we you can add also a bunch of more numbers here and then we save for ma in moving averages data frame sma underscore plus string of m a so in this case it would be sma 150 sma 200 and once we have that we say equals round and we're going to get the adjusted close value in order to calculate the moving average we need to aggregate those values and apply the mean function so we're going to say dot rolling this is how we do it in uh in pandas we say dot rolling so basically aggregating it the window that we use so the time frame is going to be m a so 150 elements or 200 elements and then on that we're going to apply the mean function um [Music] comma 2. so basically again rounding it to two decimal places there you go so now we have uh the moving averages and now we can also uh get all sorts of different values so for example we want to have the latest price the latest price is going to be adjusted close and the last value that simple the p e ratio is something that we're going to load from the yahoo finance stock info module so we're going to say p e ratio is going to be float off s i dot get quote table and we want to get from that quote table the ticker symbol and from there we want to have p e ratio ttm by the way if you want to use different values and you don't know um what the exact string is you can just look into the stock info documentation or you can i think there's a function that you can call or basically what you can do is you can just print s i get quote table ticker and you're going to see in the dictionary what kind of fields you can access so if you're interested in other statistics here um and then we're going to also get the peg ratio which is going to actually be the same no it's actually not the same because it belongs to a different function so pack ratio is float off s i dot get stats validation evaluation sorry and here the ticker and this one is a little bit more complicated because here we don't actually access um a string so we don't say pack ratio but we have to access the individual fields again here what you do if you want to look at the different fields is just say print s i dot get stats valuation ticker and you can see okay what is where in this case i have already prepared it for this video the pack ratio is at 1 4. so this is how you get the peg ratio again if you want to understand what you're doing just call this function print the result i'm not going to do it here now the moving average 150 is going to be df sma 150 negative one same thing for the 200. code is getting quite quite big here and now we're going to also get the 52-week low and the 52-week high but since we cannot start with 52 as a variable name we're going to say low 52 week which is going to be rounded the minimum of data fray data frame low from minus 52 to times five i'm going to explain the um the calculation in a second up until the end rounded to two decimal places now what we're doing here basically is we have five days a week stock trading 52 weeks and we don't want to get like 365 instances because uh then we would get also saturdays and sundays which are non-existent so we would actually look at more than 52 weeks um i don't even think that that is 100 accurate because some days you just don't have trading so maybe some special uh holidays or something uh but this is a better estimate than using uh 365. so we're going to do the same thing for the high so high 52 week is the same thing with high and with max and besides that we're going to also get the score so the score is going to be round off best performance best performers ticker equals ticker and from that instance the score which we're going to convert to a list and we're going to pick the first instance so basically we're just saying okay get the ticker symbol off or get that instance where the ticker symbol is ticker get the score value and then turn it to a list and pick it pick the first value this is just how we get the score that we calculated before and now we can start with the conditions so now we can specify what do we actually want to have in order for a stock to be accepted as something that we're interested in so we're going to say for example condition one and here you can choose whatever you want but i'm going to say condition one is just going to be that the latest price is going to have to be larger than the moving average of the last 150 days and this has to be larger than the moving average of the 200 last day so this is basically saying latest price has to be larger than that which has to be larger than that uh one condition that you could specify for example then we could also say okay the latest price has to be larger or equal to uh 1.3 times the 50 52-week low so we have to be above that low and we want to have at least 30 above that low and we can also say condition 3 is going to be the latest price has to be larger than at least 75 percent of the 52 week high so um high 52 a week and then we can also say condition for equals not latest price but p e ratio has to be less than uh less than 40 for example which is quite liberal anyways uh and the peg ratio has to be less than two just some criteria that that we could apply now in order to actually apply this condition or those conditions we now need to use the final data frame that we created up here so we're actually going to now get the stocks that apply here and we're going to say okay if condition one and condition two and condition 3 and condition 4 and condition 5 apply if all those 5 apply then we're going to say final data frame equals final data frame dot append so we're going to add to the final data frame to the screened data frame uh we're going to add a dictionary here and this is going to be the ticker is going to be the ticker the latest price is going to be the latest price by the way uh when choosing these keys here you need to make sure that you're using the same keys that you have chosen up here in the columns otherwise it's not going to work so latest price is the latest price the score is the score the pe ratio is the pe ratio the pack ratio is guess what the pack ratio the sma 150 is going to be the moving average 150 the sma 200 is going to be the moving average 200 and the 52 week low is going to be the low of 52 weeks and the 52-week high is going to be the high of 52 weeks and we're going to ignore the index so ignore index equals true there you go that is how you add it and if for some reason we get an exception here we're going to say accept exception as e we're going to print this exception for the ticker symbol all right so last but not least all we want to do is want to sort by score so we're going to say final data frame dot sort values and we're going to sort by score we're going to score descending so ascending equals false and what we're also going to do is we're going to say pd dot set option display max columns to 10 or actually yeah 10 should be enough so that we just see all the columns and not just dot dot dot in between and finally we're going to print the data frame so that we actually see the result and we're going to save it into a csv file so final df to csv final dot csv and that is it now we could theoretically just start the script and let it run over the 500 companies but this would take a very long time and of course if you want to make an actual decision it's worth the time you just leave it running for a couple of minutes maybe an hour even though an hour is way too much i think it's going to take like a couple of minutes uh but in this case i don't want to do it i don't want to run through all the 500 companies we're just going to see that it works and for this we're going to say uh counter equal zero and we're going to uh just say counter plus equals one and if counter is i don't know let's say 10 we're going to break and we're going to use those 10 companies as the bases so i'm just going to run this so that you see that it works um is this actually the right program here let me just terminate it and run it before i execute another main file yeah it wasn't the right one that is important so now it's going to run and we have a problem here no such file or directory stock data acsv this is in line 22. uh to csv what is the problem oh i think we need to create a directory first so stock data needs to be created here and now we can run this again and hopefully it works yeah seems to work so we should also probably see that or maybe if i stop it or when the script is done we're going to see it what do we have here no such keys display max columns oh i think i actually have a typo in there of course because it's not columns but columns with an n in between but it actually reached the end of the program which means that everything in between worked right so let's see didn't even take too long but okay for 10 companies it shouldn't take too long actually so what do we have here the only company of the first 10 company of the first 10 companies that survived here was apple we have a price of that we have a score of 80. uh we have a period a p e ratio of almost 30 we have a peck ratio below two so it seems like apple fulfills the requirements so we can also ease the requirements a little bit let's say the only thing that we're actually interested in is p e ratio below 40 and peg ratio below two so we just check for condition four and five maybe we're going to find more stocks if we do it like that so let's run this again and of course if you run this on 50 companies or on all 500 companies apple is not going to be the only one that fulfills this criteria but for the first 10 also you need to think about the fact that we are cutting off the worst performers even though some condition might be fulfilled by them so maybe they have a p e ratio of less than 40 maybe they have a score uh or a peg ratio below two but the score is not enough to even qualify so in this case even for those two conditions apple is the only one fulfilling it we can actually try to increase the counter here the counter limit to i don't know let's go with 30 might take a little bit longer but then i'm going to just talk about uh what we're doing here a little bit um so we're now actually just asking for p irish p e ratio less than 40 and peg ratio less than two not too difficult to fulfill given the fact that p e ratio 40 is actually quite high already and peg ratio of two is also not necessarily something that is considered a low value uh but while it's loading let's recap what we're doing here we're loading the ticker symbols we're specifying a time frame we're getting the performance of the s p 500 as a whole of the stock index uh we're preparing a final data frame we're going through all the tickers in the s p 500 if we're not limiting it with the counter here artificially for demonstration purposes so this would not be included in the final code we're calculating the same returns or the same change for all the individual stocks comparing it to the s p 500 returns determining the best performance based off or the best performers based off uh this comparison we're going through all the tickers again and then we're calculating all the important values like moving averages like last price p e ratio peg ratio moving averages 52 week lows 52 weeks highs and so on and then we specify a bunch of conditions one two three four five you can specify 20 conditions if you want to you can only specify one condition and then we apply those conditions and if a ticker symbol if a company applies uh or fulfills all those conditions it's going to be listed in the final data frame which we then sort by score in the end and we set the option so that we see all the columns and we print it and we save it to a csv file and even though i explain all that we're still not done with the uh with the actual calculations so oh there you go uh for some reason now apple is oh apple is not here probably because apple is no longer in the best performance so adm and amat i don't know both of them are better performers than apple so they so apple didn't actually qualify for the best performance because we already know that apple uh qualifies for condition number four and five but it was filtered out even before we get there because it's not part of the best performance so those two were part of the best performance and also p e ratio less than 40 and peg ratio less than two so in this case we screened those two stocks again you can just uh ignore that part if you're not interested in the best performance maybe you even want to have the worst performance for some reason so you can just turn this thing around here so that's it for today's video hope you enjoyed i hope you learned something if so let me know by hitting a like button leaving a comment in the comment section down below of course also let me know if you want to see more finance related stuff i have some videos prepared so i'm going to release more finance stuff in the near future but let me know what you think about those finance related videos stock trading crypto trading and so on analysis algorithmic trading strategy portfolio visualization and so on let me know if you want to see more of that in the comment section down below and of course don't forget to subscribe and hit the notification bell to not miss a single future video for free other than that thank you very much for watching see you next video and bye [Music] you

Original Description

In this video we code a simple stock screener in Python. DISCLAIMER: This is not investing advice. I am not a professional who is qualified in giving any financial advice. This is a video purely about programming using financial data. ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾ 📚 Programming Books & Merch 📚 🐍 The Python Bible Book: https://www.neuralnine.com/books/ 💻 The Algorithm Bible Book: https://www.neuralnine.com/books/ 👕 Programming Merch: https://www.neuralnine.com/shop 🌐 Social Media & Contact 🌐 📱 Website: https://www.neuralnine.com/ 📷 Instagram: https://www.instagram.com/neuralnine 🐦 Twitter: https://twitter.com/neuralnine 🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/ 📁 GitHub: https://github.com/NeuralNine 🎙 Discord: https://discord.gg/JU4xr8U3dm 🎵 Outro Music From: https://www.bensound.com/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from NeuralNine · NeuralNine · 0 of 60

← Previous Next →
1 Visualizing Stock Data With Candlestick Charts in Python
Visualizing Stock Data With Candlestick Charts in Python
NeuralNine
2 Python Beginner Tutorial #1 - Installation and First Program
Python Beginner Tutorial #1 - Installation and First Program
NeuralNine
3 Python Beginner Tutorial #2 - Variables and Data Types
Python Beginner Tutorial #2 - Variables and Data Types
NeuralNine
4 Python Beginner Tutorial #3 - Operators and User Input
Python Beginner Tutorial #3 - Operators and User Input
NeuralNine
5 Python Beginner Tutorial #4 - If Statements and Conditions
Python Beginner Tutorial #4 - If Statements and Conditions
NeuralNine
6 Python Beginner Tutorial #5 - Loops
Python Beginner Tutorial #5 - Loops
NeuralNine
7 Python Beginner Tutorial #6 - Sequences and Collections
Python Beginner Tutorial #6 - Sequences and Collections
NeuralNine
8 Python Beginner Tutorial #7 - Functions
Python Beginner Tutorial #7 - Functions
NeuralNine
9 Python Beginner Tutorial #8 - Exception Handling
Python Beginner Tutorial #8 - Exception Handling
NeuralNine
10 Python Beginner Tutorial #9 - File Operations
Python Beginner Tutorial #9 - File Operations
NeuralNine
11 Python Beginner Tutorial #10 - String Functions
Python Beginner Tutorial #10 - String Functions
NeuralNine
12 Python Intermediate Tutorial #1 - Classes and Objects
Python Intermediate Tutorial #1 - Classes and Objects
NeuralNine
13 Python Intermediate Tutorial #2 - Inheritance
Python Intermediate Tutorial #2 - Inheritance
NeuralNine
14 Python Intermediate Tutorial #3 - Multithreading
Python Intermediate Tutorial #3 - Multithreading
NeuralNine
15 Python Intermediate Tutorial #4 - Synchronizing Threads
Python Intermediate Tutorial #4 - Synchronizing Threads
NeuralNine
16 Python Intermediate Tutorial #5 - Events and Daemon Threads
Python Intermediate Tutorial #5 - Events and Daemon Threads
NeuralNine
17 Python Intermediate Tutorial #6 - Queues
Python Intermediate Tutorial #6 - Queues
NeuralNine
18 Python Intermediate Tutorial #7 - Sockets and Network Programming
Python Intermediate Tutorial #7 - Sockets and Network Programming
NeuralNine
19 Python Intermediate Tutorial #8 - Database Programming
Python Intermediate Tutorial #8 - Database Programming
NeuralNine
20 Python Intermediate Tutorial #9 - Recursion
Python Intermediate Tutorial #9 - Recursion
NeuralNine
21 Python Intermediate Tutorial #10 - XML Processing
Python Intermediate Tutorial #10 - XML Processing
NeuralNine
22 Python Intermediate Tutorial #11 - Logging
Python Intermediate Tutorial #11 - Logging
NeuralNine
23 Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
NeuralNine
24 Python Data Science Tutorial #2 - NumPy Arrays
Python Data Science Tutorial #2 - NumPy Arrays
NeuralNine
25 Python Data Science Tutorial #3 - Numpy Functions
Python Data Science Tutorial #3 - Numpy Functions
NeuralNine
26 Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
NeuralNine
27 Python Data Science Tutorial #5 - Subplots and Multiple Windows
Python Data Science Tutorial #5 - Subplots and Multiple Windows
NeuralNine
28 Python Data Science Tutorial #6 - Matplotlib Styling
Python Data Science Tutorial #6 - Matplotlib Styling
NeuralNine
29 Python Data Science Tutorial #7 - Bar Charts with Matplotlib
Python Data Science Tutorial #7 - Bar Charts with Matplotlib
NeuralNine
30 Python Data Science Tutorial #8 - Pie Charts with Matplotlib
Python Data Science Tutorial #8 - Pie Charts with Matplotlib
NeuralNine
31 Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
NeuralNine
32 Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
NeuralNine
33 Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
NeuralNine
34 Python Data Science Tutorial #12 - Pandas Series
Python Data Science Tutorial #12 - Pandas Series
NeuralNine
35 Python Data Science Tutorial #13 - Pandas Data Frames
Python Data Science Tutorial #13 - Pandas Data Frames
NeuralNine
36 Python Data Science Tutorial #14 - Pandas Statistics
Python Data Science Tutorial #14 - Pandas Statistics
NeuralNine
37 Python Data Science Tutorial #15 - Pandas Sorting and Functions
Python Data Science Tutorial #15 - Pandas Sorting and Functions
NeuralNine
38 Python Data Science Tutorial #16 - Pandas Merging Data Frames
Python Data Science Tutorial #16 - Pandas Merging Data Frames
NeuralNine
39 Python Data Science Tutorial #17 - Pandas Queries
Python Data Science Tutorial #17 - Pandas Queries
NeuralNine
40 Python Machine Learning Tutorial #1 - What is Machine Learning?
Python Machine Learning Tutorial #1 - What is Machine Learning?
NeuralNine
41 Python Machine Learning Tutorial #2 - Linear Regression
Python Machine Learning Tutorial #2 - Linear Regression
NeuralNine
42 Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
NeuralNine
43 Python Machine Learning #4 - Support Vector Machines
Python Machine Learning #4 - Support Vector Machines
NeuralNine
44 Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
NeuralNine
45 Python Machine Learning Tutorial #6 - K-Means Clustering
Python Machine Learning Tutorial #6 - K-Means Clustering
NeuralNine
46 Python Machine Learning Tutorial #7 - Neural Networks
Python Machine Learning Tutorial #7 - Neural Networks
NeuralNine
47 Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
NeuralNine
48 Generating Poetic Texts with Recurrent Neural Networks in Python
Generating Poetic Texts with Recurrent Neural Networks in Python
NeuralNine
49 Stock Portfolio Visualization with Matplotlib in Python
Stock Portfolio Visualization with Matplotlib in Python
NeuralNine
50 Analyzing Coronavirus with Python (COVID-19)
Analyzing Coronavirus with Python (COVID-19)
NeuralNine
51 Making Text Images Readable Again with Python and OpenCV
Making Text Images Readable Again with Python and OpenCV
NeuralNine
52 Neural Networks Simply Explained (Theory)
Neural Networks Simply Explained (Theory)
NeuralNine
53 Motion Filtering with OpenCV in Python
Motion Filtering with OpenCV in Python
NeuralNine
54 Top 5 Programming Languages To Learn in 2020
Top 5 Programming Languages To Learn in 2020
NeuralNine
55 Simple TCP Chat Room in Python
Simple TCP Chat Room in Python
NeuralNine
56 Image Classification with Neural Networks in Python
Image Classification with Neural Networks in Python
NeuralNine
57 Edge Detection with OpenCV in Python
Edge Detection with OpenCV in Python
NeuralNine
58 S&P 500 Web Scraping with Python
S&P 500 Web Scraping with Python
NeuralNine
59 Simple Sentiment Text Analysis in Python
Simple Sentiment Text Analysis in Python
NeuralNine
60 Introduction - Algorithms & Data Structures #1
Introduction - Algorithms & Data Structures #1
NeuralNine

This video teaches how to build a stock screener in Python using financial data from Yahoo Finance API and how to analyze and filter stocks based on performance. It covers data analysis, data visualization, and algorithmic trading concepts.

Key Takeaways
  1. Install pandas and yfinance libraries
  2. Load financial data from Yahoo Finance API
  3. Calculate stock performance
  4. Filter out best performers based on return compared to S&P 500
  5. Calculate moving averages, last price, P/E ratio, PEG ratio, and 52-week highs/lows
  6. Apply conditions to filter stocks and list them in a final data frame
  7. Sort data frame by score and save it to a CSV file
💡 Using a stock screener can help investors quickly identify top-performing stocks and make informed investment decisions.

Related Reads

📰
I Cut 1,300 Lines of CLAUDE.md — My Token Bill Dropped 75%
Optimize your CLAUDE.md file to reduce token spend by 75% without deleting rules
Medium · Programming
📰
Anthropic Just Dropped a Banger on “Loops” and It Quietly Changes How You Should Use Your Coding…
Learn how to use coding agents like Claude effectively with the new 'loops' concept from Anthropic
Medium · Programming
📰
AI CLI Tools Are Eating Each Other's Lunch
AI CLI tools are becoming increasingly similar, making it difficult to choose between them, and their failure patterns are identical, highlighting the need for more transparency and accountability in AI development
Dev.to · Tracepilot
📰
Loop Engineering: The Skill That Just Made Your AI Workflow Obsolete
Learn how loop engineering can automate AI workflows, making traditional prompting methods obsolete
Medium · Machine Learning
Up next
Copilot Cowork: Setup, Skills, Plugins & Pricing
Matt Tutorials
Watch →