Added total score to CSV
This commit is contained in:
parent
b6c6518ad4
commit
e1d59411fa
@ -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())
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user