Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Economic Calendar Times #331

Open
agftrading opened this issue Apr 8, 2021 · 12 comments
Open

Inconsistent Economic Calendar Times #331

agftrading opened this issue Apr 8, 2021 · 12 comments
Assignees
Labels
bug Something isn't working investing-error Investing.com related error/bug

Comments

@agftrading
Copy link

There seems to be some "randomisation" going on of the times when retrieving data from the economic calendar.

Example (run on 08/04/2021):

investpy.economic_calendar(time_zone=None,time_filter='time_only',importances=['high'],countries=['UK'])

On the first run returns:

id date time zone currency importance event actual forecast previous
426229 08/04/2021 10:30 united kingdom GBP high Construction PMI (Mar) 61.7 54.6 53.3
427371 08/04/2021 13:30 euro zone EUR high ECB Publishes Account of Monetary Policy Meeting None None None
427144 08/04/2021 14:30 united states USD high Initial Jobless Claims None 680K 719K
427152 08/04/2021 18:00 united states USD high Fed Chair Powell Speaks None None None

If I run it again it returns:

id date time zone currency importance event actual forecast previous
426229 08/04/2021 09:30 united kingdom GBP high Construction PMI (Mar) 61.7 54.6 53.3
427371 08/04/2021 12:30 euro zone EUR high ECB Publishes Account of Monetary Policy Meeting None None None
427144 08/04/2021 13:30 united states USD high Initial Jobless Claims None 680K 719K
427152 08/04/2021 17:00 united states USD high Fed Chair Powell Speaks None None None

If I run it multiple more times, it seems to switch randomly between the two sets of times.

In the above example, the first run returns incorrect (vs. what I would expect) times and the second run returns correct times. It does not make any sense to me why running exactly the same code might return different times in each case. The problem persists even if I specify the time_zone parameter explicitly.

Taking the first row of data as an example. The times are returned seemingly randomly when the code is run over and over again as outlined below.

Run with time_zone= 'GMT'. Returns, inconsistently, either 08:30 or 09:30.
Run with time_zone = 'GMT -1:00'. Returns, inconsistently, either 07:30 or 08:30.
Run with time_zone = 'GMT +1:00'. Rturns, incosistently, either 09:30 or 10:30.

@alvarobartt alvarobartt self-assigned this Apr 14, 2021
@alvarobartt alvarobartt added the bug Something isn't working label Apr 14, 2021
@alvarobartt alvarobartt added the investing-error Investing.com related error/bug label Apr 14, 2021
@alvarobartt
Copy link
Owner

Hi @agftrading, thanks for reporting this issue! 👍

I've labeled it not just as a bug but also as an Investing.com issue, as I think that the bug comes from the site and not from the Python package. Anyway, I'll reproduce the issue and try to solve it as it may also be that Investing.com updated the values from the timezones, which means that either the API method or the allowed parameters (so on the default value may be wrong, when timezone=None, which leads to this issue) are not valid anymore.

But as you mention that either using a defined timezone or its default value timezone=None, the times seem to be "random", so my guess is that the request parameters have been updated, maybe on the spring hour change some weeks ago... Also to let you know that Investing.com provides more than one identifier per GMT timezone so that the election is random between all the allowed values...

Thanks for reporting this! Consider it done or at least checked in the next couple of days 🔥

@agftrading
Copy link
Author

That is great. Thanks!

@alvarobartt alvarobartt added this to the investpy v1.0.8 milestone Jun 16, 2021
@mpresence
Copy link

Hi,

May I know when this issue will be resolved?

@alvarobartt
Copy link
Owner

Hi @mpresence I didn't have time until now to work on my projects, but now I do, so I'll try to work on most of the relevant issues/bugs during this weekend so that later I can also focus on the feature requests 👍🏻

@mpresence
Copy link

Thanks @alvarobartt you have done a great job with this...keep it up 😊

@rodrigoperales
Copy link

Maybe it's not the correct way of fixing this problem, I'm still a newbie in programming, but in the file "utils/constant.py" I modified the "TIMEZONES" set and only left one element for each time zone list, and now the function gives me the same hours, it doesn't switch anymore. I think the problem comes from there, some numbers in the lists dont correspond to the correct GMT zones.

@alvarobartt
Copy link
Owner

Mmm thanks for spotting that @rodrigoperales! TBH that may be the issue, but as far as I could check in the past in Investing.com they are using those selectors... Anyway I'll check this further later today so as to provide you a more detailed answer tomorrow!

So on, in case that's the issue feel free to open a PR once I give you a more detailed answer 👍🏻

@rodrigoperales
Copy link

I did a inspection to see the values of the timezones in investing's website and these are the correct values now:

TIMEZONES = {
'GMT -11:00': [2,35],
'GMT -10:00': [3],
'GMT -8:00': [4],
'GMT -7:00': [37,36,5],
'GMT -6:00': [38,6],
'GMT -5:00': [42,39,7,40,41],
'GMT -4:00': [9,45,8,46,43],
'GMT -3:00': [44,10,12,48,49,51,47],
'GMT -2:30': [11],
'GMT -2:00': [50],
'GMT -1:00': [53],
'GMT': [14,55,56],
'GMT +1:00': [54,15,166,60],
'GMT +2:00': [16,57,58,65,67,59,61],
'GMT +3:00': [62,71,64,66,68,63,17,70,18,72],
'GMT +3:30': [19],
'GMT +4:00': [20,73],
'GMT +4:30': [21],
'GMT +5:00': [22,77],
'GMT +5:30': [23,79],
'GMT +5:45': [24],
'GMT +6:00': [25],
'GMT +6:30': [26],
'GMT +7:00': [27],
'GMT +8:00': [28,178,113],
'GMT +9:00': [29,88],
'GMT +10:00': [91,94],
'GMT +10:30': [30],
'GMT +11:00': [31,32],
'GMT +12:00': [1],
'GMT +13:00': [33]
}

I checked it a little bit to see if it worked and it did.
The problem I see with this approach is that they might change again in future, specially after next sunday time change in Europe at least.

I wish I could help more and made this more automatic but i lack the knowledge.

Thanks by the way for this amazing work.

@alvarobartt
Copy link
Owner

Thanks for the support and the kind words @rodrigoperales! 🤗

No worries, I'll try that and I will also be looking forward to the time change so as to see whether those values change or not, so as to provide a more consistent solution, since using static data (not super easy to update) is obviously not the desired solution.

FYI I'm planning to deprecate as much of the static data as I can for investpy v2.0 🎉 Anyway, not sure whether that will be possible or not, still some more months of refactoring and testing stuff!

@rodrigoperales
Copy link

That sounds great, it must be difficult to do that. Thanks

@stevenm100
Copy link

Thanks @rodrigoperales this worked for me
#331 (comment)

@albertcuspi
Copy link

@rodrigoperales Hi Rodrigo, how did you get the values for the variable TIMEZONE in investings website?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investing-error Investing.com related error/bug
Projects
None yet
Development

No branches or pull requests

6 participants