alvarobartt / investiny

🤏🏻 `investpy` but made tiny
https://alvarobartt.github.io/investiny
MIT License
280 stars 32 forks source link

Issue with Date and Price mapping #40

Closed KapsTrvl closed 1 year ago

KapsTrvl commented 1 year ago

Opening new ticket per #31 @alvarobartt

Historical price query for US10Y returning incorrect Date and Price mapping. Getting weekend date 10/08/22 (Sat) and missing 10/10/22(Mon) per the following - image image

Thanks for looking into this.

alvarobartt commented 1 year ago

I've already checked and it seems it's not due to the timezone conversion to UTC, I can also see data for 10/08/2022 while it shouldn't as your correctly pointing out @KapsTrvl, but I'll explore the issue further as the API that we're using is https://tvc4.investing.com/ not Investing.com defaults API, so the results may vary from the ones shown in the website... Anyway I'll explore this further and come back with an answer ASAP :hugs:

alvarobartt commented 1 year ago

Ok, it seems that all the dates are being shifted by one day when transforming the timestamps into datetime objects so I'll keep on exploring that... See that the screenshot below shows the retrieved dates as well as the close value, compared to the ones available at Investing.com, there seems to be a 1-day difference.

image

image
alvarobartt commented 1 year ago

Ok this is directly related to the timezone conversion done internally by Investing.com so that the results are presented in the timezone they operate, not in UTC format, so I've got a way to fix that, so consider this to be done later today, and investiny v0.7.0 to be released!

alvarobartt commented 1 year ago

@KapsTrvl make sure to install the latest release as pip install investiny --upgrade and the following code should work fine!

from investiny import historical_data

data = historical_data(investing_id=23705, from_date="10/04/2022", to_date="10/14/2022")
print(data["date"])