Download financial statements from Yahoo Finance with Python

  Рет қаралды 19,831

Python enthusiast

Python enthusiast

3 жыл бұрын

Support the channel via the links below:
Paypal: www.paypal.com/donate?hosted_...
www.buymeacoffee.com/Kostadin
This is part 2 of the Fundamental analysis with Python tutorial series, covering how to set up the library and download financial statements using Python.
The tutorial series would be using the yahoo finance Python library (link below) to extract financial statements. Based on the scraped data, various criteria would be created that would assess the strength of the company's position.
Link to library:
theautomatic.net/yahoo_fin-doc...
How to install: pypi.org/project/yahoo-fin/
Link to Piotroski F-score:
en.wikipedia.org/wiki/Piotros...
Link to GitHub code: github.com/kosta93/Fundamenta...

Пікірлер: 53
@Ukeloverdarsh
@Ukeloverdarsh 2 жыл бұрын
Thanks so much, Man, this is the simplest video on how to extract data. I am glad that you have addressed the issue of financial years being different for companies. Awesome video! Please make more videos, I can't explain how much this video has helped me!
@Pythonenthusiast
@Pythonenthusiast 2 жыл бұрын
I am very happy to read this! I might be doing some livestreams on working with some financial statements and maybe create a stock screener based on certain criteria :)
@golamkabirmohammad696
@golamkabirmohammad696 Жыл бұрын
Hello, you have siimplied a difficult concept , great learning videos. Thanks a TON..
@zedbot123
@zedbot123 3 жыл бұрын
Very well explained, thank you!
@clarence2c408
@clarence2c408 3 жыл бұрын
Good, I look forward for your videos soon
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
By the end of the week, the entire series will be out :) Thanks for your kind comment!
@hermanusbernardusswart4690
@hermanusbernardusswart4690 2 жыл бұрын
This video is very helpful. Thank you!
@francoforte274
@francoforte274 2 жыл бұрын
Thank you! Great video, really helpful!! I was wondering if is possible to take a single data such as ‘total assets’ instead of the whole balance sheet?
@yuchaogong1619
@yuchaogong1619 2 жыл бұрын
Thank you! It is really helpful! But I have one question: how should I code what if I want to get the balance sheet data for more than 4 years? (10 years for example?)
@pwarme
@pwarme 2 жыл бұрын
Hi - I;m finding this very useful, but while I'm able to get a list of tickers, I am getting an error when tring to run the get_balance_sheet method for example: "IndexError: list index out of range" Any ideas what might be going wrong here?
@artem1339
@artem1339 3 жыл бұрын
I hope you will make one for Joel's "Magic Formula". Thank you for the video!
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
Hey Artem, thanks for the recommendation, it is much appreciated! I haven't heard yet about Joel's "Magic Formula", but will do my research and write the code for it.
@jamesmathew8428
@jamesmathew8428 Жыл бұрын
thank you for the video. I got an error while trying to run it. Empty DataFrame Columns: [] Index: []
@tailiu2525
@tailiu2525 2 жыл бұрын
How do I get more than 4 period of balance sheet data? like if I want to go back and get the last eight quarters of balance sheet data?
@danielmercieca2887
@danielmercieca2887 3 жыл бұрын
Well done!
@david69973
@david69973 2 жыл бұрын
Hi ! How are you connecting with the api ? Mine says module implemented in the videos are not valid modules.
@chriswong8586
@chriswong8586 Жыл бұрын
Thank you for sharing, but I found that yahoo_fin get_balance_sheet() doesn't return any data. Any suggestion? Thanks.
@manuelmbscorreia
@manuelmbscorreia 3 жыл бұрын
Amazing!
@uwakmfonjoshua5435
@uwakmfonjoshua5435 Жыл бұрын
Great video, but yahoo finance is not functional now anymore, what is the alternative?
@cjfeat.2631
@cjfeat.2631 2 жыл бұрын
two thumbs up!!
@jamesbldwn1
@jamesbldwn1 6 ай бұрын
In similar to other comments, the get_balance_sheet function will return me an empty data frame, when I do the get_income_statement function, I get a 'string indices must be integers, not str'. I have been researching for answers to these problems and can't figure it out :(. Otherwise this video is great
@HYDEN212
@HYDEN212 3 жыл бұрын
Good video thank you!!!
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
Glad you liked it!
@albertibekwe2147
@albertibekwe2147 3 жыл бұрын
great video you have gained a subscriber and a like
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
Thanks a lot! :)
@wirtschaftswissenschaften
@wirtschaftswissenschaften Жыл бұрын
Hi. I wanted to ask you something. Suppose I want to find out if the profit of a list of companies has increased steadily every year for the last 5 years. How would you do this so that you get all the companies listed that in the last 5 years their profits have increased steadily each year?
@Pythonenthusiast
@Pythonenthusiast Жыл бұрын
You've already laid down the logic :) You need the data for the last 5 years (profit-related) per company and you have to decide whether you are happy with the criteria for increase every single year. If that is the case, you'd have to compare year 2 to year 1, year 3 to year 2, year 4 to year 3 and so on. If at any of these comparisons, there's a down year, the script can stop and move to the next company.
@VR-fh4im
@VR-fh4im Жыл бұрын
Yahoo_fin uses pandas append() method and it gives warning all over the code. This will break in next version of Pandas.
@koz.b1741
@koz.b1741 3 жыл бұрын
can you make a tutorial on collecting data from a bunch of stocks and exporting them? thanks for the content
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
Hey there. Well, once you have the data downloaded, all you need to do is export it to a csv file. I don't think I'll make a separate video on it as it is fairly easy to be done. Could you take a look at the link below? datatofish.com/export-dataframe-to-csv/
@koz.b1741
@koz.b1741 3 жыл бұрын
@@Pythonenthusiast thanks for taking your time to reply. I will definately take a look. appreciate it
@smartboyambwani21
@smartboyambwani21 11 ай бұрын
I can help you
@eshawilson771
@eshawilson771 2 жыл бұрын
Man, thank you for the video. Is there a way to get data for more than four years? Coz I am trying to get the 10-year data. Thank you again for the wonderful video : )
@Pythonenthusiast
@Pythonenthusiast 2 жыл бұрын
Hey Esha, sorry for the late reply. I am not sure if data older than 5 years can be extracted from any (free) source, at least I haven't found such a source yet.
@vitalien6572
@vitalien6572 3 жыл бұрын
Thanks a lot for your video. Please do a tutorial about Magic formula strategy from Joel Greeanblatt!!!
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
Hey there, thanks for the suggestion, I've received another message on this before. It is on my list. I went through the formula and I see quite some flaws from an accounting point of view, but I will find a way to create a tutorial series on it, hopefully in the next month.
@showyourbrain
@showyourbrain 3 жыл бұрын
Man, thank you for the video, you have given me an idea how I can handle my PhD dissertation in easier way. Though I'm not so tech-savvy and have no clue in Python (but have got some experience with R), I'm now wondering if it's possible to extract selected data from financial statements basing on the technique you described in the video? For instance I don't need all these numbers from income statements, except for Revenue, Operating Income, and R&D expenses (for 3 years or more). How to extract only those three variables and put them into excel or excel-like table? I would really appreciate your response as anyone's else responses as well, because I'm doing this procedure manually, scrolling 10k by 10k... Also, if it's possible to extract from YF website any financial statement data older than 3 years? And thanks once again for your video, have subscribed and will be watching more.
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
Hey there, thanks for the kind words. I'll try to help as much as I can. 1. Regarding the extraction of data into an excel file, it is absolutely possible. Here's what I would do if I was in your shoes: Step 1: Think of the structure of your data (your end-goal). I assume that you would ideally want to have 5 columns in your excel file: Company name, Revenue, Operating income, R&D expense and financial year. Step 2: Use the pandas library and start by creating an empty pandas dataframe (Think of this as an empty excel file) that has the columns mentioned above. Step 3: Create a function that takes the 3 numbers that you need, Revenue, Operating income & R&D expense. Keep in mind that the argument that this function would need is the financial year. Step 4: Create a for loop, that would loop into the X amount of years that you need and would run the function for that particular year. Step 5: The last step in the loop would be, to create a row of data (Think of it as an excel row), that would consist the 5 elements as mentioned in step 1. This row would be added to the pandas dataframe that was created in step 2. Step 6: Once the dataframe is completed, you can export the dataframe to a csv file. There are plenty of things that can go wrong, so maybe good to start iterating in a small part of the list of stocks to make sure it works and account for any error that might occur along the way. 2. Regarding the YF website, you can extract the data that is available on their website, I think it is last 4 years. Hope this helps and good luck!
@showyourbrain
@showyourbrain 3 жыл бұрын
@@Pythonenthusiast Thank you so much again, Kostadin. You described the procedure very explicitly, I'll try to figure it out. I'm really grateful for this piece of advice. However if YF website provides with last 4 years data only, then for my research problem I still need to work manually with income statements for the companies I sampled, since I need to include data from the period of 2015-2019 (5 years in total). But I've noted your answer for the future, would be nice to use the technique you described for the other research problems. I wish you all the best and hope you'll continue sharing new videos ;)
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
@@showyourbrain I understand that it is for your PhD dissertation and I am not sure if you can have 4 years as a period instead of 5. Also, I am not sure if the outcome of your analysis would change significantly by having additional data points taking into account that if you analyzing the S&P 500 for 4 years, that's already 2.000 rows of data. As of today, I've added a link on my "about" page that allows my viewers to schedule a 30-minutes meeting with me, so if you want to discuss this, feel free to do so :)
@showyourbrain
@showyourbrain 3 жыл бұрын
@@Pythonenthusiast I see. The thing is that I had already justified my choice of 5 years period for analysis by literature I found -- roughly speaking it takes at least 5 years for R&D investment to turn into profits. Besides 5 years is the shortest period mentioned in related literature, in case of my topic it's better to take even longer period of analysis as there're publications say it takes 7 years on average for R&D investment to generate return, or it depends on industry so the researcher has to set conditions for each industry separately. But my research proposal is already approved so there's only little I can revise without consuming much time... I'll try to find some other databases like YF that contain financial statement data for the period I need and for the companies listed at NYSE and NASDAQ (not all, I chose about 200). So if you know any websites, even premium-based, I'd really appreciate once again. Otherwise I still have much time to collect everything manually :)
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
​@@showyourbrain Ah well, then I guess there are 2 solutions: 1. Use a paid source of data (There are plenty of websites out there) and use Python to combine them into one table. 2. Use web scraping and scrape the data you need from the SEC. The first one is more expensive in terms of money, while the second one costs more time.
@kelvinso3858
@kelvinso3858 2 жыл бұрын
Thanks so much. It's really useful. It is much clear than my professor. lamo
@Pythonenthusiast
@Pythonenthusiast 2 жыл бұрын
I am glad you enjoyed the video! :)
@hardikvegad3508
@hardikvegad3508 3 жыл бұрын
Amazing video man...But how can we do this for multiple companies such as GOOG, KO, nflx all at once. and what will be your approach for a question like this: Use Yahoo Finance to collect Financial data for Indian companies (min 100 companies). I hope you will reply thank you.
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
Hey there, that is a good question. You can store the tickers for all companies in a list: Example: companies = ['GOOG', 'KO', 'NFLX'] and so on. Then, you create a function that would require a ticker and it would contain everything that you would like to get from the function, i.e. extracting data and saving it as .csv for example. So, def extract_data(ticker): *Insert all the code here* Once these two steps are completed, you can run a for loop. for company in companies: extract_data(company) I hope this helps!
@hardikvegad3508
@hardikvegad3508 3 жыл бұрын
@@Pythonenthusiast Actually, the question I am facing is something like this: Train a Classifier to classify stress companies vs non-stress companies. 1.) Use Yahoo Finance to collect Financial data for Indian companies (min 100 companies). 2.) Convert financial variables into features based on the following ratios. - Current ratio - Debt to equity ratio - ROI (Return on investment) - ROA (Return on assets) - Inventory turnover ratio. - Net profit margin - Perform EDA(exploratory data analysis) on features. I am just facing an issue with data fetching. Other tasks I can do it.
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
What is the issue that you are facing? I cannot follow your question. The data fetching is something that is being covered at the beginning of this tutorial series. Could you please elaborate on your question?
@josephkennady820
@josephkennady820 Жыл бұрын
Hey@@Pythonenthusiast, I am not able to fetch the data for Indian stocks. I used tickers = yf.tickers_nse How will you change this as an array list? ['GOOG', 'KO', 'NFLX'] Thank you!
@DiegoTorres-jw8xo
@DiegoTorres-jw8xo 3 жыл бұрын
Hello, Is there a way to download all the symbols that yahoo finance contains in stocks, etfs, crypto, etc? I have only found this function "pdr.get_nasdaq_symbols ()" but it is only for the nasdaq symbols and I would like to see those of the Chinese stock exchange. Thank you very much, I loved your video.
@Pythonenthusiast
@Pythonenthusiast 3 жыл бұрын
Hi Juan, I haven't seen an option for that yet. Probably the best approach would be to try to download all symbols from another source and integrate through them.
@DiegoTorres-jw8xo
@DiegoTorres-jw8xo 3 жыл бұрын
@@Pythonenthusiast Thank you very much my friend!!
Fundamental analysis of profitability with Python
15:04
Python enthusiast
Рет қаралды 6 М.
[3] Importing financial statements from a webpage using Python
13:27
Pythonic Accountant
Рет қаралды 15 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 8 МЛН
Дарю Самокат Скейтеру !
00:42
Vlad Samokatchik
Рет қаралды 8 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 57 МЛН
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 9 МЛН
Financial Data with Python: yfinance
34:09
Data Science for Everyone
Рет қаралды 68 М.
Why Python is huge in finance? by Daniel Roos
31:52
PyCon Sweden
Рет қаралды 184 М.
SAVING TIME: Scraping Financial Data
18:21
Spencer Pao
Рет қаралды 10 М.
Fundamental Analysis of Stocks with Python
19:09
Algovibes
Рет қаралды 27 М.
Fundamental (Financial statements) analysis with Python - Introduction
6:15
Introduction to Python for Finance
25:27
Richard Moglen
Рет қаралды 198 М.
Fundamental analysis of liquidity and leverage with Python
13:45
Python enthusiast
Рет қаралды 2,7 М.
SHAP with Python (Code and Explanations)
15:41
A Data Odyssey
Рет қаралды 53 М.
Financial Data with Python: S&P 500 Data
10:39
Data Science for Everyone
Рет қаралды 10 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 8 МЛН