summaryrefslogtreecommitdiff
path: root/backend/app/services/data_service.py
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2026-06-14 02:33:50 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2026-06-14 02:33:50 -0700
commit4571fc6a82f4190896bc7fe952cb747bba4aa8a1 (patch)
tree53331c0ec521c887dcc24fa1a9ee407ab9542344 /backend/app/services/data_service.py
parent88cbfebfc4b45f95e8d24edf3cc265a03ecbd695 (diff)
fix: clean up get_sec_filings (cache decorator, url shadowing, dead code, imports)
Diffstat (limited to 'backend/app/services/data_service.py')
-rw-r--r--backend/app/services/data_service.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/backend/app/services/data_service.py b/backend/app/services/data_service.py
index e9f3dab..caa8294 100644
--- a/backend/app/services/data_service.py
+++ b/backend/app/services/data_service.py
@@ -1,9 +1,11 @@
"""yfinance wrapper for Prism v2 Overview data."""
from __future__ import annotations
+import datetime
import math
import os
import statistics
+from collections import defaultdict
from typing import Any
import httpx
@@ -1881,10 +1883,7 @@ _FORM_DESCRIPTIONS: dict[str, str] = {
"SC 13D": "Beneficial ownership (active)",
}
-_PRIMARY_FORMS = {"10-K", "10-Q", "8-K"}
-
-
-@cached(cache=FILINGS_CACHE)
+@cached(FILINGS_CACHE)
def get_sec_filings(symbol: str) -> dict:
"""Fetch and pre-process SEC filings for a ticker.
@@ -1892,9 +1891,6 @@ def get_sec_filings(symbol: str) -> dict:
Data source: yfinance `sec_filings`. FMP fallback if FMP_API_KEY is set
and yfinance returns empty.
"""
- import datetime
- from collections import defaultdict
-
sym = normalize_symbol(symbol)
raw: list[dict] = []
@@ -1928,7 +1924,7 @@ def get_sec_filings(symbol: str) -> dict:
title = str(r.get("title") or _FORM_DESCRIPTIONS.get(form, form)).strip()
# URL: prefer primary form exhibit, fall back to edgarUrl/link
exhibits = r.get("exhibits") or {}
- url = exhibits.get(form) or r.get("edgarUrl") or r.get("link") or None
+ filing_url = exhibits.get(form) or r.get("edgarUrl") or r.get("link") or None
if not date_raw or not form:
continue
@@ -1944,7 +1940,7 @@ def get_sec_filings(symbol: str) -> dict:
except (ValueError, TypeError):
continue
- items.append({"date": date_str, "form": form, "title": title, "url": url})
+ items.append({"date": date_str, "form": form, "title": title, "url": filing_url})
# Sort descending by date
items.sort(key=lambda x: x["date"], reverse=True)