Python Error Fix

This commit is contained in:
samchen 2025-10-08 22:50:16 -05:00
parent 32be17c606
commit 3491cb4a88
2 changed files with 5 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import pandas as pd
import json import json
from datetime import datetime from datetime import datetime
from io import StringIO from io import StringIO
from typing import Union
API_BASE_URL = "https://www.alphavantage.co/query" API_BASE_URL = "https://www.alphavantage.co/query"
@ -39,7 +40,7 @@ class AlphaVantageRateLimitError(Exception):
"""Exception raised when Alpha Vantage API rate limit is exceeded.""" """Exception raised when Alpha Vantage API rate limit is exceeded."""
pass pass
def _make_api_request(function_name: str, params: dict) -> dict | str: def _make_api_request(function_name: str, params: dict) -> Union[dict, str]:
"""Helper function to make API requests and handle responses. """Helper function to make API requests and handle responses.
Raises: Raises:

View File

@ -1,6 +1,7 @@
from .alpha_vantage_common import _make_api_request, format_datetime_for_api from .alpha_vantage_common import _make_api_request, format_datetime_for_api
from typing import Union
def get_news(ticker, start_date, end_date) -> dict[str, str] | str: def get_news(ticker, start_date, end_date) -> Union[dict[str, str], str]:
"""Returns live and historical market news & sentiment data from premier news outlets worldwide. """Returns live and historical market news & sentiment data from premier news outlets worldwide.
Covers stocks, cryptocurrencies, forex, and topics like fiscal policy, mergers & acquisitions, IPOs. Covers stocks, cryptocurrencies, forex, and topics like fiscal policy, mergers & acquisitions, IPOs.
@ -24,7 +25,7 @@ def get_news(ticker, start_date, end_date) -> dict[str, str] | str:
return _make_api_request("NEWS_SENTIMENT", params) return _make_api_request("NEWS_SENTIMENT", params)
def get_insider_transactions(symbol: str) -> dict[str, str] | str: def get_insider_transactions(symbol: str) -> Union[dict[str, str], str]:
"""Returns latest and historical insider transactions by key stakeholders. """Returns latest and historical insider transactions by key stakeholders.
Covers transactions by founders, executives, board members, etc. Covers transactions by founders, executives, board members, etc.