-
Notifications
You must be signed in to change notification settings - Fork 389
Open
Description
Did a rerun of a code that worked at the start of 2025, now unfortunately it is not functional anymore. Did they change something on the Investing.com side? If anyone knows what happened, we could look into this together. Code:
class GetInvesting:
def __init__(self, start_date="2024-01-01", end_date="2025-01-01"):
self.start_date = self.ensure_ddmmyyyy(start_date)
self.end_date = self.ensure_ddmmyyyy(end_date)
self.today = dt.date.today().strftime("%d_%m_%Y")
@staticmethod
def ensure_ddmmyyyy(date_str):
try:
dt.datetime.strptime(date_str, "%d/%m/%Y") # Already in DD/MM/YYYY
return date_str
except ValueError:
return dt.datetime.strptime(date_str, "%Y-%m-%d").strftime("%d/%m/%Y")
def fetch(self):
"""Fetch the economic calendar."""
try:
xstart_date = dt.datetime.strptime(self.start_date, "%d/%m/%Y")
xend_date = dt.datetime.strptime(self.end_date, "%d/%m/%Y")
# Fetch the economic calendar data
x = inv.news.economic_calendar(from_date=self.start_date, to_date=self.end_date)
if 'date' in x.columns:
x['date'] = pd.to_datetime(x['date'], format='%d/%m/%Y').dt.strftime('%Y-%m-%d')
file_path = f"investpy_test/{xstart_date.strftime('%Y%m%d')}_{xend_date.strftime('%Y%m%d')}_econcalendar_investingcom.csv"
x.to_csv(file_path, index=False)
print(f"Economic calendar data saved to {file_path}")
print('GetInvesting Done')
except Exception as e:
print(f"Error fetching economic calendar: {e}")
Metadata
Metadata
Assignees
Labels
No labels