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

some stock id's give an error #25

Open
andresrogers opened this issue Oct 8, 2022 · 8 comments
Open

some stock id's give an error #25

andresrogers opened this issue Oct 8, 2022 · 8 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@andresrogers
Copy link

andresrogers commented Oct 8, 2022

For some ids, historical_data gives this error:

historical_data(investing_id=40654,from_date=start_date_1, to_date=end_date_1)

also

historical_data(investing_id=26490,from_date=start_date_1, to_date=end_date_1)

for dates:
start_date_1 = '04/27/2000'
end_date_1 = '04/26/2012'

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_16762/3915976534.py in <module>
----> 1 historical_data(investing_id=26490,from_date=start_date_1, to_date=end_date_1)

~/.local/lib/python3.10/site-packages/investiny/historical.py in historical_data(investing_id, from_date, to_date, interval)
     46     time_format = "%H:%M %m/%d/%Y" if isinstance(interval, int) else "%m/%d/%Y"
     47     output = {
---> 48         "date": [datetime.fromtimestamp(t).strftime(time_format) for t in data["t"]],  # type: ignore
     49         "open": data["o"],  # type: ignore
     50         "high": data["h"],  # type: ignore

KeyError: 't'
@alvarobartt
Copy link
Owner

Hi @andresrogers, where are you retrieving those IDs from? If those are being retrieved from investpy static files, just to let you know that those files are not consistent as those were statically generated some time ago, and have potentially changed. So the available data there may not be the actual one.

Anyway, let me know the Investing.com URL of the asserts corresponding to the investing_id=29490 and investing_id=40654IDs so as to explore the issue further.

Thanks! 👍🏻

@alvarobartt alvarobartt self-assigned this Oct 9, 2022
@alvarobartt alvarobartt added the invalid This doesn't seem right label Oct 9, 2022
@andresrogers
Copy link
Author

andresrogers commented Oct 9, 2022

The ones that gave me an error are:

investing_id=26490 is META

search_assets(query="META", limit=1)
{'symbol': 'META',
'full_name': 'NASDAQ:META',
'description': 'Meta Platforms Inc',
'type': 'Stock',
'ticker': '26490',
'exchange': 'NASDAQ'}

investing_id=40654 is TLT

search_assets(query="TLT", limit=1)
{'symbol': 'TLT',
'full_name': 'NASDAQ:TLT',
'description': 'iShares 20+ Year Treasury Bond ETF',
'type': 'ETF',
'ticker': '40654',
'exchange': 'NASDAQ'},

It only gave me that error if I used '04/27/2000' as starting date, didn't get the error for less than 10 years difference to current date.

@alvarobartt
Copy link
Owner

alvarobartt commented Oct 9, 2022

Ok @andresrogers let me try and I'll come back to you with a response 👍🏻 But I assume it may have something to do with #24 as it just happens whenever you use too distant dates.

@ramakrishnamekala129
Copy link

ramakrishnamekala129 commented Oct 10, 2022

              open        high         low       close

date
2012-05-18 42.049999 45.000000 38.000000 38.230000
2012-05-21 36.529999 36.660000 33.000000 34.029999
2012-05-22 32.610001 33.590000 30.940001 31.000000
2012-05-23 31.370001 32.500000 31.360001 32.000000
2012-05-24 32.950001 33.209999 31.770000 33.029999
... ... ... ... ...
2022-10-04 140.490005 142.390106 139.339996 140.279999
2022-10-05 138.240005 140.210007 134.779999 138.979996
2022-10-06 137.714996 141.449997 136.600006 139.070007
2022-10-07 136.759995 138.289993 132.440002 133.449997
2022-10-10 133.550003 135.940002 132.800003 134.100006

@ramakrishnamekala129
Copy link

it gave error because this api doesnt have 2012-05-18 before data this stock

@andresrogers
Copy link
Author

it gave error because this api doesnt have 2012-05-18 before data this stock

I thought something of the sort, but I believe the expected behaviour should be to return the earliest possible data without giving an error.

@alvarobartt
Copy link
Owner

Thanks for posting that @ramakrishnamekala129, and yes, @andresrogers, the expected behavior is not to fail, so I'll check it and come back with a response ASAP 👍

@alvarobartt
Copy link
Owner

it gave error because this api doesnt have 2012-05-18 before data this stock

I thought something of the sort, but I believe the expected behaviour should be to return the earliest possible data without giving an error.

We should be creating a separate issue for this once the new version is released! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants