-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
🥅 Handle data limits from each Investing.com request #27
Conversation
As done in `investpy`, it seems that Investing.com APIs are limited to a certain number of data points, in this case the limit seems to be in 19 years (for "D" interval only)
This function has been created so as to support the calculation of datetimes for all the available intervals, as https://tvc4.investing.com is limited, otherwise results will be shortened
Handle both supported date formats, improve timezone conversion just for "D", "W", and "M" intervals (fixes problem with today's data #28), and add some useful comments.
Hi, I was testing this branch. I wanted to mention a usecase to know how to handle it. This call fails with error investiny/src/investiny/utils.py Lines 44 to 53 in acdc5c2
PS.: I am sorry for intruding into this branch:) |
Sure, makes sense, but I'll need to figure out how! |
What if we return an empty dict when there is |
Well that will work for sure, but ideally we should avoid sending too many requests to Investing.con so I'll try to do it during the interval calculation, and then also to return an empty dict in that scenario! |
Yes, if there is a way to eliminate empty data time intervals and find the actual |
Type-hints are already defined in the function args, so there's no need to add that information in the docstrings too.
If `from_date` is provided and `to_date` is not, then `to_date` defaults to current date in UTC format.
Also intervals: 45, 120, and 240, have been removed as those have been included recently and most of the assets don't have those among their `intraday_multipliers`
Used via `znck.grammarly` VSCode extension.
✨ Features
to_date
param's default value to the current daterequest_to_investing
error handling🐛 Bug Fixes
interval="D"
the maximum amount of data to retrieve is 19 years of data, just like ininvestpy
)%m/%d/%Y
dates to UTC, as for theUTC+
timezones, it was reducing the date by the hours skew, which was resulting in wrong historical data retrieval resultscalculate_date_intervals
aswhile
loop was calculatingto_datetime
minusfrom_datetime
difference, when what had to be calculated for the loop to continue for more than one iteration wasmax_to_datetime
minusto_datetime
🔮 TODOs
45, 60,120,240, 300)interval="D"
on 5000 results%H:%M %m/%d/%Y
for bothfrom_date
andto_date
-> At the end we decided to use%m/%d/%Y %H:%M
instead📌 Additional Information
It seems that both https://tvc4.investing.com and https://tvc6.investing.com APIs have a limitation of 5000 results, which for
interval="D"
seems something easy to calculate, while for intra-day intervals is a little bit harder as the amount of minutes/hours in a trading day depends on the exchange, but we'll be calculating an estimation over NASDAQ or NYSE assets, as those are the most active ones, so as to overestimate the intervals and make sure we don't lose data.🔗 Linked Issue/s
#24 #28 #31
🧪 Tests
If the above checkbox is checked, describe how you unit-tested it.
In order to test
historical_data
with wider date ranges, we've included a new unit test namedtest_historical_wide_range
and two new values for bothfrom_date
andto_date
namedfrom_date_wide_range
andto_date_wide_range
, so as to make sure that we can retrieve daily (interval="D"
) data of more than 19 years.