From c0285bb0c7628d021a12f4be9f999ffb38ca93ca Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Thu, 6 Feb 2025 18:59:10 -0800 Subject: [PATCH] feat: Integrate I_Score for institutional sponsorship in CANSLIM screener --- src/main.py | 4 ++++ src/screener/csv_appender.py | 2 ++ src/screener/screeners.py | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 1e1e777..b45e428 100644 --- a/src/main.py +++ b/src/main.py @@ -3,6 +3,7 @@ from screener.data_fetcher import validate_date_range, fetch_financial_data, get from screener.c_canslim import check_quarterly_earnings, check_return_on_equity, check_sales_growth from screener.a_canslim import check_annual_eps_growth from screener.l_canslim import check_industry_leadership # ✅ NEW: Import L Score function +from screener.i_canslim import check_institutional_sponsorship # ✅ NEW: Import I Score function from screener.csv_appender import append_scores_to_csv from screener.screeners import SCREENERS # Import categories from screener.user_input import get_user_screener_selection # Import function @@ -52,6 +53,9 @@ def main(): elif screener == "L_Score": scores[screener] = check_industry_leadership(symbol) # ✅ NEW: Industry Leadership Calculation print(f"🟢 {symbol} - L_Score: {scores[screener]}") # ✅ DEBUG LOG + elif screener == "I_Score": + scores[screener] = check_institutional_sponsorship(symbol) # ✅ NEW: Institutional Sponsorship Check + print(f"🏢 {symbol} - I_Score: {scores[screener]}") # ✅ DEBUG LOG # Apply user-defined threshold if applicable if isinstance(threshold, (int, float)): diff --git a/src/screener/csv_appender.py b/src/screener/csv_appender.py index 1cb721f..35a2dfb 100644 --- a/src/screener/csv_appender.py +++ b/src/screener/csv_appender.py @@ -30,6 +30,8 @@ def append_scores_to_csv(symbol, scores): headers = existing_headers if existing_headers else new_headers if "L_Score" not in headers: headers.insert(-1, "L_Score") # Ensure L_Score is before Total_Score + if "I_Score" not in headers: + headers.insert(-1, "I_Score") # Ensure I_Score is before Total_Score # Ensure order consistency for output row_data = {header: scores.get(header, 0) for header in headers} diff --git a/src/screener/screeners.py b/src/screener/screeners.py index acae5b3..25084f7 100644 --- a/src/screener/screeners.py +++ b/src/screener/screeners.py @@ -5,7 +5,8 @@ SCREENERS = { "Annual_EPS_Score": "Checks 3-year annual EPS growth", "Sales_Score": "Checks quarterly sales growth", "ROE_Score": "Checks return on equity", - "L_Score": "Checks if the stock is a leader in its industry" # ✅ NEW: Added L_Score + "L_Score": "Checks if the stock is a leader in its industry", # ✅ NEW: Added L_Score + "I_Score": "Checks institutional sponsorship and ownership trends" # ✅ NEW: Added I_Score }, "Volume-Based": { "Volume_Oscillator_Score": "Checks for unusual volume surges",