Files
All-in-one-Financial-Analysis/views/tab4_news.py
T
shawnkim1997andClaude Sonnet 4.6 d337c63976 refactor: modular architecture v3.0 + SEC filing viewer fix + README
Architecture (3,909-line monolith → 28 focused modules, all < 300 lines):
- config/: constants.py (company lists, row maps, Damodaran baselines), theme.py (CSS/HTML)
- utils/: prefs, formatting, ticker, dcf, charts, ui_helpers
- data/: sec_parser, sec_fetcher, sec_downloader, financials, fundamentals,
         valuation, ratios, scores, scores_ai, market
- ai/: gemini_core, gemini_sec, gemini_insights
- views/: sidebar, tab1_quant, tab1_ai, tab1_filings, tab2_dcf,
          tab3_comps, tab4_news, tab5_markets, tab6_crypto, tab7_technical
- app.py: thin orchestrator (~118 lines)
- Strict unidirectional dependency graph (no circular imports)
- All @st.cache_data TTLs and st.session_state keys preserved identically

SEC filing viewer fix:
- Rebuilt EDGAR fetch chain: company_tickers.json → CIK → submissions API
  → filings.recent.primaryDocument[] (replaces deprecated directory.item)
- Filing type selectbox (10-K, 10-Q, 8-K, 20-F, 6-K) connected to backend
- Native HTML rendered via streamlit.components.v1.html() with CSS reset
- Errors surfaced explicitly with st.error()
- DART direct links restored for Korean-listed companies

.gitignore: data/ → data/*.json + data/*.html (preserve Python modules)
README: full rewrite for master's portfolio — 7-tab layout, architecture
diagram, modular structure tree, technical challenges, design rationale

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 22:11:07 +00:00

28 lines
1.2 KiB
Python

import streamlit as st
from config.constants import COMPANY_TICKER_MAP
from data.market import _fetch_news_rss
def render_tab4(ticker):
st.subheader("News Feed")
st.caption(f"Latest news for **{ticker}**")
try:
import feedparser
news_items = _fetch_news_rss(ticker, COMPANY_TICKER_MAP.get(ticker, ""))
if news_items:
for item in news_items:
st.markdown(f"""
<div style="background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); border-radius: 8px; padding: 12px 16px; margin-bottom: 8px;">
<a href="{item['url']}" target="_blank" style="color: #F3F4F6; text-decoration: none; font-weight: 600; font-size: 0.95rem;">
{item['title']}
</a>
<div style="color: #6B7280; font-size: 0.75rem; margin-top: 4px;">
{item['source']} \u00b7 {item['published'][:25] if item['published'] else ''}
</div>
</div>
""", unsafe_allow_html=True)
else:
st.info("No news found. Try a different ticker.")
except ImportError:
st.warning("Install `feedparser` to enable news feed: `pip install feedparser`")