From e1d59411fa13e14c52e3ac1db8dc7260620160f5 Mon Sep 17 00:00:00 2001 From: Bobby Abellana Date: Mon, 3 Feb 2025 22:14:12 -0800 Subject: [PATCH] Added total score to CSV --- src/screener/csv_appender.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/screener/csv_appender.py b/src/screener/csv_appender.py index 1373733..9d5e6f7 100644 --- a/src/screener/csv_appender.py +++ b/src/screener/csv_appender.py @@ -1,7 +1,7 @@ import csv import os -# Get the absolute path to the `data/metrics/` directory (outside `src/`) +# Define the directory and generic CSV file path BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) # Go two levels up METRICS_DIR = os.path.join(BASE_DIR, "data", "metrics") CSV_FILE = os.path.join(METRICS_DIR, "stock_scores.csv") @@ -12,11 +12,17 @@ def append_scores_to_csv(symbol, scores): Args: symbol (str): Stock ticker symbol. - scores (dict): Dictionary of metric scores (e.g., C_Score, Sales_Score, etc.). + scores (dict): Dictionary of metric scores (e.g., EPS_Score, Sales_Score, Annual_EPS_Score, etc.). """ # Ensure the directory exists os.makedirs(METRICS_DIR, exist_ok=True) + # Compute the total score (sum of all numeric values in scores) + total_score = sum(scores.values()) + + # Include `Total_Score` in the scores dictionary + scores["Total_Score"] = total_score + # Define the header dynamically based on the provided scores headers = ["Symbol"] + list(scores.keys())