diff --git a/alphavantage_api_client/client.py b/alphavantage_api_client/client.py index fd98fe6..2559a7d 100644 --- a/alphavantage_api_client/client.py +++ b/alphavantage_api_client/client.py @@ -1064,7 +1064,7 @@ def get_top_gainers_and_losers(self) -> MarketMovers: return MarketMovers.model_validate(json_response) - def get_earnings_calendar(self, event: Union[str, dict]) -> EarningsCalendar: + def get_earnings_calendar(self, event: Union[str, dict] = dict()) -> EarningsCalendar: """Returns a list of company earnings expected in the next 3, 6, or 12 months. Returns: @@ -1073,9 +1073,11 @@ def get_earnings_calendar(self, event: Union[str, dict]) -> EarningsCalendar: """ defaults = { "function": "EARNINGS_CALENDAR", - "horizon": "3month", + "horizon": "6month", "datatype": "csv", } + if event is None: + event = dict() json_request = self.__create_api_request_from__(defaults, event) json_response = self.get_data_from_alpha_vantage(json_request, self.__retry__) records = json_response["csv"].split("\n") diff --git a/tests/test_all_free_endpoints.py b/tests/test_all_free_endpoints.py index ef206dd..ec060b7 100644 --- a/tests/test_all_free_endpoints.py +++ b/tests/test_all_free_endpoints.py @@ -685,8 +685,7 @@ def test_get_earnings_calendar(self): @pytest.mark.integration def test_get_earnings_calendar_all(self): - event = {"horizon": "6month", "datatype":"csv"} # 6 months so we are sure to get data - earnings_calendar = self.get_client().get_earnings_calendar(event) + earnings_calendar = self.get_client().get_earnings_calendar() assert ( earnings_calendar.success ), f"success was found to be True which is unexpected: {earnings_calendar.error_message}"