Skip to content

Instantly share code, notes, and snippets.

@alvarobartt
Created December 17, 2019 20:00
Show Gist options
  • Save alvarobartt/0b3d48b1d6360c6a0ebd6a64c49c6a2c to your computer and use it in GitHub Desktop.
Save alvarobartt/0b3d48b1d6360c6a0ebd6a64c49c6a2c to your computer and use it in GitHub Desktop.
investpy search functionallity explained
# Required investpy version 0.9.10 or higher (0.9.12 recommended)
import investpy
# As asked on issue #86 -> https://github.com/alvarob96/investpy/issues/86
# this gist will explain `investpy.search_text` function usage for Swedish
# bonds that are not statically stored on investpy/resources/bonds/bonds.csv
# file, since its data is not provided by Investing on its general government
# bonds listing.
search_results = investpy.search_text(text='Sweden 10 Year', count=10)
# Iter through the search results (class instances of `investpy.utils.search_obj.SearchObj`.
for search_result in search_results:
print(search_result) # As self.__str__ function is implemented search result content can be printed.
if search_result.pair_type == 'bond':
data = search_result.retrieve_recent_data()
print(data.head()) # or print(search_result.data.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment