Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hjones20/fundamental-analysis
Screen stocks on fundamentals and estimate their intrinsic value
https://github.com/hjones20/fundamental-analysis
fundamental-analysis personal-finance stock-data stock-screener
Last synced: 3 months ago
JSON representation
Screen stocks on fundamentals and estimate their intrinsic value
- Host: GitHub
- URL: https://github.com/hjones20/fundamental-analysis
- Owner: hjones20
- Created: 2020-04-15T03:47:56.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-11T15:16:30.000Z (over 4 years ago)
- Last Synced: 2024-07-10T16:59:09.739Z (7 months ago)
- Topics: fundamental-analysis, personal-finance, stock-data, stock-screener
- Language: Python
- Homepage: https://financialmodelingprep.com/
- Size: 21.7 MB
- Stars: 60
- Watchers: 6
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starts - hjones20/fundamental-analysis - Screen stocks on fundamentals and estimate their intrinsic value (others)
README
# Fundamental Analysis
Fundamental Analysis is a program that allows me to screen stocks using fundamental indicators and estimate the intrinsic value of qualified stocks using the Discounted Cash Flow method of valuation.**The logic accomplishes 5 primary tasks:**
1. Downloads all stock tickers available via the FinancialModelingPrep API and generates profiles on each company
2. Retrieves and cleans financial statement data on each company
3. Screens companies on any chosen indicators of value (ex: 8-Year Median ROE)
4. Plots the stability of core indicators over an N-year period
- Includes: EPS, Dividend Per Share, Book Value per Share, ROE, Current Ratio, Debt to Equity Ratio
5. Estimates the intrinsic value, margin of safety value for chosen companies![alt text](https://github.com/hjones20/fundamental-analysis/blob/master/fundamental/images/EPS-scaled.png?raw=true)
## Functions
I've listed the available functions separated by module below for anyone that wishes to build upon this logic.**Notes:**
1. The FinancialModelingPrep API appears to be updated frequently. As a result, changes in data availability / functionality may occur.
2. It is not necessary to use the functions prefixed with the word **'calculate'** in the **company_fundamentals** module in order to calculate the intrinsic value of a company. You can get a given company's discounted cash flow directly from the FinancialModeling Prep API here. I simply opted to build the DCF logic myself in order to better understand how it works. It was not a great programming choice as errors will result if column names change.
- FinancialModelingPrep also offers a tutorial on the discounted cash flow methodology here.- **company_profiles**
- `get_company_data` - Retrieves 'symbol', 'name', 'price', and 'exchange' information for all available stock tickers
- `select_stock_exchanges` - Filters out stock tickers that are not listed on one of the major exchanges: 'Nasdaq Global Select', 'NasdaqGS', 'Nasdaq', 'New York Stock Exchange', 'NYSE', 'NYSE American'
- `select_minimum_price` - Filters out stock tickers that have a price less than the one specified by the user
- `create_company_profile` - Retrieves additional company information for each stock ticker provided, writes data to csv file, stores file in the specified directory
- **company_financials**
- `select_sector` - Filters out stock tickers that do not belong to the specified sectors
- `select_industries` - Filters out stock tickers that do not belong to the specified industries
- `get_financial_data` - Retrieves any of the following financial datasets for each of the stock tickers provided: Financial Statements, Financial Ratios, Financial Growth, Key Company Metrics, Enterprise Value
- `clean_financial_data` - Scans DataFrame containing financial data on N stock stickers and removes rows with corrupted date values. Adds a new 'year' column as well for future use
- `select_analysis_years` - Remove stock tickers without financial reports in a specified timeframe (ex: L10Y) and subset DataFrame to only include the years specified (ex: 2015 - 2020)
- **company_fundamentals**
- `combine_data` - Read and join all files in a specified directory (ex: 'data/') with a specified year pattern (ex: '2Y')
- `calculate_stats` - Calculate the mean, median, or percent change of provided columns over an N-year period
- `screen_stocks` - Filter out stock tickers with column values that do not fall within specified ranges
- `plot_performance` - Plot stock performance over time with respect to the following column values: 'Earnings per Share', 'Dividend per Share', 'Book Value per Share', 'Return on Equity', 'Current Ratio', 'Debt to Equity Ratio'. Note that 'Dividend per Share' is commented out as the column name seems to have disappeared in a recent API update
- `prepare_valuation_inputs` - Subset DataFrame to include only the data required for Discounted Cash Flow model calculations
- `calculate_discount_rate` - Calculated the Weighted Average Cost of Capital (WACC) for each stock ticker provided
- `calculate_discounted_free_cash_flow` - Calculate the present value of discounted future cash flows for each stock ticker provided
- `calculate_terminal_value` - Calculate the terminal value for each stock ticker for each stock ticker provided
- `calculate_intrinsic_value` - Calculate the intrinsic value of each stock ticker provided
- `calculate_margin_of_safety` - Calculate the margin of safety value of each stock ticker provided## References
- **Data Sources:** All stock data is pulled from the FinancialModelingPrep API
- **Graphs:** The "Stability Graph" concept was taken from the great folks at www.buffettsbooks.com. They explain why this concept is so important here
- **Calculations:** Guides to the Discounted Cash Flow method of valuation can be found in many places across the internet. Personally, I used the Advanced Value Investing Udemy course