Open GMScodes opened 3 years ago
Hi @GMScodes, thanks for this feature proposal! :fire:
Currently, you can retrieve the index futures using investpy.search_quotes()
even though there's no static data for those yet, this function uses the Investing.com search engine so that you can access any Investing.com financial product!
Here's an example of how to use it:
>>> import investpy
>>> search_result = investpy.search_quotes(text='nasdaq futures', products=['indices'], countries=['united states'], n_results=1)
>>> print(search_result)
{"id_": 8874, "name": "NASDAQ Futures", "symbol": "USTEC", "country": "united states", "tag": "/indices/nq-100-futures", "pair_type": "indices", "exchange": ""}
>>> recent_data = search_result.retrieve_recent_data()
>>> historical_data = search_result.retrieve_historical_data(from_date='01/01/2020', to_date='01/01/2021')
>>> information = search_result.retrieve_information()
More information available at [Wiki - investpy.search_quotes()
](https://github.com/alvarobartt/investpy/wiki/investpy.search_quotes()). Feel free to ask me anything related to this functionality in the meantime! :+1:
@GMScodes also, if you want to retrieve more financial products, feel free to increase the n_results
value so that instead of receiving a single investpy.SearchObj
class instance, you receive a list
of investpy.SearchObj
class instances.
Another tip is that before retrieving the information you can print each search result so as to see the dict
with its values so as to check that it's the one you are looking for. And, finally, so as to further explore the functionality you can play around with the Investing.com search engine from the browser so as to compare the results you see on the website with the ones you receive in the call to investpy.search_quotes()
so that you fully understand its functionality.
Thank you so much!!!
Is there any way to get
Hi @GMScodes, thanks for this feature proposal! 🔥
Currently, you can retrieve the index futures using
investpy.search_quotes()
even though there's no static data for those yet, this function uses the Investing.com search engine so that you can access any Investing.com financial product!Here's an example of how to use it:
>>> import investpy >>> search_result = investpy.search_quotes(text='nasdaq futures', products=['indices'], countries=['united states'], n_results=1) >>> print(search_result) {"id_": 8874, "name": "NASDAQ Futures", "symbol": "USTEC", "country": "united states", "tag": "/indices/nq-100-futures", "pair_type": "indices", "exchange": ""} >>> recent_data = search_result.retrieve_recent_data() >>> historical_data = search_result.retrieve_historical_data(from_date='01/01/2020', to_date='01/01/2021') >>> information = search_result.retrieve_information()
More information available at [Wiki -
investpy.search_quotes()
](https://github.com/alvarobartt/investpy/wiki/investpy.search_quotes()). Feel free to ask me anything related to this functionality in the meantime! 👍
Is there any way to get "last" price when using search quotes? As there is no 'get overview' for search results, I haven't managed to retrieve the last price for a search quote.
Hi @ribboo, note that the Close
value of the current day if the market is still open, is the Last
value as established by Investing.com. So this means that I can either implement a function retrieve_last_value
for every SearchObj
class instance or you can just retrieve_recent_data
and then keep the last close value of the pandas.DataFrame
.
Here's a simple example I hope you find useful:
>>> import investpy
>>> search_result = investpy.search_quotes(text='S&P 500 Futures', products=['indices'], countries=['United States'], n_results=1)
>>> print(search_result)
{"id_": 8839, "name": "S&P 500 Futures", "symbol": "US500", "country": "united states", "tag": "/indices/us-spx-500-futures", "pair_type": "indices", "exchange": ""}
>>> recent_data = search_result.retrieve_recent_data()
>>> print(recent_data.tail())
Open High Low Close Volume
Date
2021-05-03 4187.88 4202.38 4178.88 4179.38 0
2021-05-04 4179.88 4184.38 4120.62 4159.62 0
2021-05-05 4159.38 4179.88 4153.12 4160.12 0
2021-05-06 4160.38 4198.00 4140.62 4194.12 0
2021-05-07 4194.12 4203.62 4191.88 4199.12 0
>>> current_value = recent_data.iloc[-1]['Close']
>>> print(current_value)
4199.12
Cheers! 👍🏻
Note: this issue will be closed once the Index Futures
functions are implemented, and merged from the PR #185
Kindly consider adding pull request for index futures historical data as this is useful for tracking index when main markets are closed. If you add this feature, it would be of enormous help to me :) I am sure it will be of help to other people as well. Thanks & regards in advance.