A Python script to classify companies based on financial metrics like the Piotroski F-Score and Stock Valuation. It processes CSV financial data for multiple companies and outputs a classification (Strong
, Medium
, or Weak
) for each company.
- Computes Piotroski F-Score based on profitability, leverage, and efficiency metrics.
- Calculates Stock Valuation using P/E Ratio and P/B Ratio.
- Classifies companies into
Strong
,Medium
, orWeak
based on their metrics. - Handles missing or invalid financial data gracefully.
- Saves the results as a CSV file.
- Loads financial data from CSV files for specified company tickers.
- Computes the following metrics:
- Piotroski F-Score: Combines 9 financial metrics to score financial health.
- Stock Valuation: The sum of P/E Ratio and P/B Ratio.
- Classifies companies based on the metrics:
Strong
: F-Score β₯ 7 and Valuation < 20Medium
: F-Score β₯ 4 and Valuation < 30Weak
: All others
- Outputs a CSV file with the results.
Ensure you have Python 3.7+ and the following Python libraries installed:
pip install pandas
. Directory Setup
Organize your data in the following structure:
Copy
Edit
financial_data/
β
βββ GM_ratios.csv
βββ GM_cash_flow.csv
βββ GM_balance_sheet.csv
βββ GM_income_statement.csv
βββ TSLA_ratios.csv
βββ TSLA_cash_flow.csv
βββ TSLA_balance_sheet.csv
βββ TSLA_income_statement.csv
βββ AAPL_ratios.csv
βββ AAPL_cash_flow.csv
βββ AAPL_balance_sheet.csv
βββ AAPL_income_statement.csv
3. Run the Script
Save the script as stock_picker.py, and execute it: