Spaces:
Sleeping
Sleeping
Akshit Chaturvedi commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -62,16 +62,22 @@ graph TD
|
|
| 62 |
|
| 63 |
Detailed Calculation Walkthrough
|
| 64 |
Here is an in-depth explanation of each step in the valuation process.
|
|
|
|
|
|
|
| 65 |
Step 1: Data Acquisition (get_stock_data)
|
| 66 |
The pipeline begins by fetching all necessary raw data for the selected ticker from yfinance. This includes:
|
| 67 |
Company Profile: Market data like market cap, beta, and the number of shares outstanding.
|
| 68 |
Financial Statements: The last 4-5 years of the Income Statement, Balance Sheet, and Cash Flow Statement.
|
|
|
|
|
|
|
| 69 |
Step 2: Key Metrics Calculation (calculate_metrics)
|
| 70 |
The raw data is processed to calculate two crucial metrics for our analysis:
|
| 71 |
Operating Margin: A measure of core business profitability.
|
| 72 |
Formula: Operating Income / Total Revenue
|
| 73 |
Free Cash Flow (FCF): The cash a company generates after accounting for capital expenditures. This is the bedrock of the DCF model.
|
| 74 |
Formula: Cash from Operating Activities - Capital Expenditures
|
|
|
|
|
|
|
| 75 |
Step 3: Weighted Average Cost of Capital (calculate_wacc)
|
| 76 |
The WACC is the discount rate used to bring future cash flows back to their present value. It represents the blended cost of a company's financing and is a critical input for the DCF model. It is calculated in three parts:
|
| 77 |
A. Cost of Equity (Re): Calculated using the Capital Asset Pricing Model (CAPM).
|
|
@@ -80,6 +86,8 @@ B. Cost of Debt (Rd): The effective rate the company pays on its debt.
|
|
| 80 |
Formula (Proxy): Interest Expense / Total Debt
|
| 81 |
C. The WACC Formula: The final weighted average.
|
| 82 |
Formula: (Equity Weight * Re) + (Debt Weight * Rd * (1 - Tax Rate))
|
|
|
|
|
|
|
| 83 |
Step 4: Discounted Cash Flow (DCF) Valuation (run_dcf_valuation)
|
| 84 |
This model calculates the company's intrinsic value based on its ability to generate future cash.
|
| 85 |
Forecast FCF: The model projects the company's Free Cash Flow for the next 5 years. The growth rate is based on the company's historical Compound Annual Growth Rate (CAGR) of revenue, which is then gradually tapered down to a conservative perpetual growth rate.
|
|
@@ -88,6 +96,8 @@ Formula (Gordon Growth): (Final Year FCF * (1 + Perpetual Growth Rate)) / (WACC
|
|
| 88 |
Discount to Present Value: All projected FCFs and the terminal value are discounted back to today using the WACC. The sum of these is the Enterprise Value.
|
| 89 |
Calculate Equity Value: The model subtracts the company's Net Debt (Total Debt - Cash) from the Enterprise Value to arrive at the total value attributable to shareholders.
|
| 90 |
Final Value: The Equity Value is divided by the number of shares outstanding to get the final intrinsic value per share.
|
|
|
|
|
|
|
| 91 |
Step 5: Comparable Company (Comps) Valuation (run_comps_valuation)
|
| 92 |
This model provides a relative valuation based on how the market is pricing similar companies.
|
| 93 |
Identify Peers: A predefined list of close competitors is used.
|
|
@@ -96,6 +106,8 @@ Apply Multiple: This median multiple is multiplied by the target company's own E
|
|
| 96 |
Formula: Target Company EBITDA * Peer Median EV/EBITDA
|
| 97 |
Calculate Equity Value: Just like in the DCF model, Net Debt is subtracted from the Implied Enterprise Value to get the Implied Equity Value.
|
| 98 |
Final Value: The Implied Equity Value is divided by shares outstanding to get the final market-based value per share.
|
|
|
|
|
|
|
| 99 |
Step 6 & 7: Synthesis and Final Decision (analyze_stock)
|
| 100 |
This is the final step where all the analysis comes together.
|
| 101 |
Blend Valuations: The application takes a simple average of the DCF and Comps values to create a single, blended Avg. Intrinsic Value.
|
|
@@ -104,12 +116,5 @@ Formula: (Average Intrinsic Value / Current Price) - 1
|
|
| 104 |
Apply Margin of Safety: A final decision is made based on a 25% margin of safety.
|
| 105 |
Rule: If Upside Potential > 25%, the decision is "Buy". Otherwise, it is "Hold/Not Buy".
|
| 106 |
Display Final Metrics: The summary table is populated with the final valuation numbers and the new, reliable metrics: Operating Margin (a measure of profitability) and Beta (a measure of risk).
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
Click the "Analyze Stock" button.
|
| 110 |
-
The application will fetch the latest financial data in real-time and display the complete valuation summary in the table below.
|
| 111 |
-
How to Run Locally
|
| 112 |
-
Clone this repository.
|
| 113 |
-
Install the required packages: pip install -r requirements.txt
|
| 114 |
-
Run the application: python app.py
|
| 115 |
-
Open the local URL provided in your browser.
|
|
|
|
| 62 |
|
| 63 |
Detailed Calculation Walkthrough
|
| 64 |
Here is an in-depth explanation of each step in the valuation process.
|
| 65 |
+
|
| 66 |
+
|
| 67 |
Step 1: Data Acquisition (get_stock_data)
|
| 68 |
The pipeline begins by fetching all necessary raw data for the selected ticker from yfinance. This includes:
|
| 69 |
Company Profile: Market data like market cap, beta, and the number of shares outstanding.
|
| 70 |
Financial Statements: The last 4-5 years of the Income Statement, Balance Sheet, and Cash Flow Statement.
|
| 71 |
+
|
| 72 |
+
|
| 73 |
Step 2: Key Metrics Calculation (calculate_metrics)
|
| 74 |
The raw data is processed to calculate two crucial metrics for our analysis:
|
| 75 |
Operating Margin: A measure of core business profitability.
|
| 76 |
Formula: Operating Income / Total Revenue
|
| 77 |
Free Cash Flow (FCF): The cash a company generates after accounting for capital expenditures. This is the bedrock of the DCF model.
|
| 78 |
Formula: Cash from Operating Activities - Capital Expenditures
|
| 79 |
+
|
| 80 |
+
|
| 81 |
Step 3: Weighted Average Cost of Capital (calculate_wacc)
|
| 82 |
The WACC is the discount rate used to bring future cash flows back to their present value. It represents the blended cost of a company's financing and is a critical input for the DCF model. It is calculated in three parts:
|
| 83 |
A. Cost of Equity (Re): Calculated using the Capital Asset Pricing Model (CAPM).
|
|
|
|
| 86 |
Formula (Proxy): Interest Expense / Total Debt
|
| 87 |
C. The WACC Formula: The final weighted average.
|
| 88 |
Formula: (Equity Weight * Re) + (Debt Weight * Rd * (1 - Tax Rate))
|
| 89 |
+
|
| 90 |
+
|
| 91 |
Step 4: Discounted Cash Flow (DCF) Valuation (run_dcf_valuation)
|
| 92 |
This model calculates the company's intrinsic value based on its ability to generate future cash.
|
| 93 |
Forecast FCF: The model projects the company's Free Cash Flow for the next 5 years. The growth rate is based on the company's historical Compound Annual Growth Rate (CAGR) of revenue, which is then gradually tapered down to a conservative perpetual growth rate.
|
|
|
|
| 96 |
Discount to Present Value: All projected FCFs and the terminal value are discounted back to today using the WACC. The sum of these is the Enterprise Value.
|
| 97 |
Calculate Equity Value: The model subtracts the company's Net Debt (Total Debt - Cash) from the Enterprise Value to arrive at the total value attributable to shareholders.
|
| 98 |
Final Value: The Equity Value is divided by the number of shares outstanding to get the final intrinsic value per share.
|
| 99 |
+
|
| 100 |
+
|
| 101 |
Step 5: Comparable Company (Comps) Valuation (run_comps_valuation)
|
| 102 |
This model provides a relative valuation based on how the market is pricing similar companies.
|
| 103 |
Identify Peers: A predefined list of close competitors is used.
|
|
|
|
| 106 |
Formula: Target Company EBITDA * Peer Median EV/EBITDA
|
| 107 |
Calculate Equity Value: Just like in the DCF model, Net Debt is subtracted from the Implied Enterprise Value to get the Implied Equity Value.
|
| 108 |
Final Value: The Implied Equity Value is divided by shares outstanding to get the final market-based value per share.
|
| 109 |
+
|
| 110 |
+
|
| 111 |
Step 6 & 7: Synthesis and Final Decision (analyze_stock)
|
| 112 |
This is the final step where all the analysis comes together.
|
| 113 |
Blend Valuations: The application takes a simple average of the DCF and Comps values to create a single, blended Avg. Intrinsic Value.
|
|
|
|
| 116 |
Apply Margin of Safety: A final decision is made based on a 25% margin of safety.
|
| 117 |
Rule: If Upside Potential > 25%, the decision is "Buy". Otherwise, it is "Hold/Not Buy".
|
| 118 |
Display Final Metrics: The summary table is populated with the final valuation numbers and the new, reliable metrics: Operating Margin (a measure of profitability) and Beta (a measure of risk).
|
| 119 |
+
|
| 120 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|