diff --git a/live_price_display.py b/live_price_display.py index 27b1788..7908755 100755 --- a/live_price_display.py +++ b/live_price_display.py @@ -6,7 +6,7 @@ import pandas as pd # import psycopg2 -from src.parameters import ALPHA_VANTAGE_API_KEY # type: ignore[attr-defined] +# from src.parameters import ALPHA_VANTAGE_API_KEY # type: ignore[attr-defined] ALPHA_VANTAGE_ENDPOINT = "https://www.alphavantage.co/query" @@ -16,43 +16,43 @@ class LivePriceDisplay: Returns the most recent price of the selected company. """ - @staticmethod - def display_final_price_av(company_name: str) -> Union[str, dict, Any]: - """ - Returns a the price using Alpha Vantage. + # @staticmethod + # def display_final_price_av(company_name: str) -> Union[str, dict, Any]: + # """ + # Returns a the price using Alpha Vantage. - Args: - company_name: The ticker symbol of the company. + # Args: + # company_name: The ticker symbol of the company. - Returns: - The most recent price. - """ - try: - # Gets last available price by default - price_params: dict = { - "apikey": ALPHA_VANTAGE_API_KEY, - "function": "TIME_SERIES_DAILY", - "symbol": company_name, - } - price_response: requests.models.Response = requests.get( - ALPHA_VANTAGE_ENDPOINT, params=price_params, timeout=20 - ) - if price_response.ok: - response_data: dict = price_response.json() - if "Time Series (Daily)" in response_data: - price_list: dict = response_data["Time Series (Daily)"] - most_recent_day: str = next(iter(price_list)) - return price_list[most_recent_day]["4. close"] - return response_data - return price_response + # Returns: + # The most recent price. + # """ + # try: + # # Gets last available price by default + # price_params: dict = { + # "apikey": ALPHA_VANTAGE_API_KEY, + # "function": "TIME_SERIES_DAILY", + # "symbol": company_name, + # } + # price_response: requests.models.Response = requests.get( + # ALPHA_VANTAGE_ENDPOINT, params=price_params, timeout=20 + # ) + # if price_response.ok: + # response_data: dict = price_response.json() + # if "Time Series (Daily)" in response_data: + # price_list: dict = response_data["Time Series (Daily)"] + # most_recent_day: str = next(iter(price_list)) + # return price_list[most_recent_day]["4. close"] + # return response_data + # return price_response - except ( - requests.exceptions.MissingSchema, - requests.RequestException, - KeyError, - IndexError, - ): - return "Error fetching price" + # except ( + # requests.exceptions.MissingSchema, + # requests.RequestException, + # KeyError, + # IndexError, + # ): + # return "Error fetching price" @staticmethod def display_final_price_yf(company_name: str) -> Union[float, str]: diff --git a/news_display.py b/news_display.py index 553875b..9a5c90d 100755 --- a/news_display.py +++ b/news_display.py @@ -1,8 +1,8 @@ """This module displays the most recent news of the selected company if available""" import requests +import streamlit as st -from src.parameters import NEWS_API_KEY # type: ignore[attr-defined] NEWS_ENDPOINT = "https://newsapi.org/v2/everything" @@ -22,7 +22,7 @@ def _collect_news(company_name: str) -> list: Returns: five_article: The most recent five articles """ - news_params: dict = {"apiKey": NEWS_API_KEY, "qInTitle": company_name} + news_params: dict = {"apiKey": st.secrets.connections.newsapi["apiKey"], "qInTitle": company_name} news_response: requests.models.Response = requests.get( NEWS_ENDPOINT, params=news_params, timeout=20