alvarobartt / investpy

Financial Data Extraction from Investing.com with Python
https://investpy.readthedocs.io/
MIT License
1.59k stars 374 forks source link

Incorrect Dates on investpy.economic_calendar #603

Open sobcza11 opened 1 year ago

sobcza11 commented 1 year ago

Hello,

Before I begin, investpy is awesome & helped tremendously on one of my Data Science capstone projects; big fan of the work on investpy.

That said, I am experiencing some issues on the dates for investpy.economic_calendar; notably some are wrong. I included my Python code below for reference as to what I am puling. I will note, it is a long time horizon.

today_d_m_y = now.strftime("%d/%m/%Y")

us_econ = pd.DataFrame([]) us_econ = investpy.economic_calendar( countries = ['United States'], categories = ['date', 'time','zone', 'importance', 'event', 'actual', 'forecast'], from_date = '01/01/2005', to_date = today_d_m_y)

us_econ = us_econ[::-1] us_econ = us_econ.sort_values(by=['date'], ascending=False) us_econ = us_econ.reset_index(drop=True)

I put all of this into an excel & pull separate economic items separately. Below is an example on US CPI (YoY).

us_cpi = pd.DataFrame([]) us_cpi = us_econ[us_econ['event'].str.startswith('CPI (YoY)')]

some come as only CPI (YoY) but most have the relevant date behind it; the below shows only those with the date behind it

us_cpi = us_cpi.loc[us_cpi["event"] != 'CPI (YoY)' ]

us_cpi = us_cpi.reset_index(drop=True) us_cpi = us_cpi.sort_values(by=['date'], ascending=False)

This code shows a 2022-12-04 ( which hasn't happened yet...now is 18 Sept 2022 ) for CPI (YoY) (Mar). I included some screen shots. That said, that could be structured as YYYY-DD-MM " but" another further below (8) has the structure different as YYYY-MM-DD. The confusion lays in the flip flop.

1_investpy 2_investpy 3_investpy 4_investpy

Any thoughts or possible errors I'm making to make it work?

Please advise.

Rand

sobcza11 commented 1 year ago

@alvarobartt Any thoughts?