import finnhub from streamlit import secrets finhub_api = secrets["finhub_api"] from datetime import datetime, timedelta def get_finhub(ticker): finhub_list = [] def get_yesterday(frmt='%Y-%m-%d', string=True): yesterday = datetime.now() - timedelta(days=1) if string: return yesterday.strftime(frmt) return yesterday from datetime import datetime def get_today(frmt='%Y-%m-%d'): today = datetime.now() return today.strftime(frmt) # Example usage: today = get_today() # Output: '2024-02-04' # Example usage: yesterday = get_yesterday() finnhub_client = finnhub.Client(api_key=f"{finhub_api}") data = finnhub_client.company_news(ticker, _from=yesterday, to=today) for article in data: finhub_list.append(article['headline']) return finhub_list