Skip to content

Commit

Permalink
Merge pull request #95 from xrgarcia/92-get_earnings_calendar-should-…
Browse files Browse the repository at this point in the history
…allow-for-no-params

event dict for get earnings callendar is optional so you can get all …
  • Loading branch information
xrgarcia authored Aug 17, 2023
2 parents f74eb78 + 8173feb commit e616e0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions alphavantage_api_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions tests/test_all_free_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit e616e0a

Please sign in to comment.