import os import logging from typing import Any from dotenv import load_dotenv import finnhub load_dotenv() api_key = os.getenv('FINNHUB_API_TOKEN') def fetch_comp_financial_news(ticker: str = 'NVDA', date_from = "2025-07-31", date_to = "2025-08-01") -> list[dict[str, Any]] | None: """ Fetch financial news using Finnhub API. """ try: finnhub_client = finnhub.Client(api_key=api_key) news_feed = finnhub_client.company_news(ticker, _from=date_from, to=date_to) logging.info(f'got total amount of news: {news_feed} for ticker: {ticker}') except Exception as e: logging.info(f"Error fetching financial news: {e}") return None