Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions investpy/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def economic_calendar(
categories=None,
from_date=None,
to_date=None,
lang=None,
):
"""
This function retrieves the economic calendar, which covers financial events and indicators from all over the world
Expand Down Expand Up @@ -139,7 +140,16 @@ def economic_calendar(
"ERR#0114: the introduced date value must be a string unless it is None."
)

url = "https://www.investing.com/economic-calendar/Service/getCalendarFilteredData"
if lang is not None and not isinstance(lang, str):
raise ValueError(
"ERR#0139: the introduced lang value must be a string unless it is None."
)

host = "www.investing.com"
if lang == "korean":
host = "kr.investing.com"

url = f"https://{host}/economic-calendar/Service/getCalendarFilteredData"

headers = {
"User-Agent": random_user_agent(),
Expand Down Expand Up @@ -178,9 +188,9 @@ def economic_calendar(

end_date = datetime.strptime(to_date, "%d/%m/%Y")

if start_date >= end_date:
if start_date > end_date:
raise ValueError(
"ERR#0032: to_date should be greater than from_date, both formatted as"
"ERR#0032: to_date should be equal to from_date or greater than from_date, both formatted as"
" 'dd/mm/yyyy'."
)

Expand Down
2 changes: 1 addition & 1 deletion investpy/utils/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
"GMT -7:00": [37, 38, 6],
"GMT -6:00": [39, 7, 40, 41],
"GMT -5:00": [42, 8, 43],
"GMT -4:00": [10, 9, 45, 46],
"GMT -4:00": [9, 45, 46],
"GMT -3:30": [11],
"GMT -3:00": [44, 12, 48, 49, 50, 51, 47],
"GMT -1:00": [14, 53],
Expand Down