Last active
July 20, 2019 09:16
-
-
Save alvarobartt/461dce00d9196dd3140f37993f8808f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python3.x | |
import investpy | |
import pandas as pd | |
import random | |
from pprint import pprint | |
# This function retrieves all the available equities indexed on es.Investing.com | |
available_equities = investpy.get_equities_list() | |
pprint(available_equities) | |
# As a test, you can either pick a random one or just pass as parameter a specific one | |
random_equity = random.choice(available_equities) | |
print(random_equity) | |
selected_equity = 'bbva' | |
# Once we select an equity, we can get its recent historical data or specify a range of | |
# time to retrieve historical data from using the following functions respectively. In this | |
# case we will be retrieving the information as a pandas.DataFrame, but we can also retrieve | |
# it as a json file, for more information type in terminal: help(get_recent_data) or | |
# help(get_historical_data) | |
recent_df = investpy.get_recent_data(equity=selected_equity, | |
as_json=False, | |
order='ascending') | |
print(recent_df.head()) | |
historical_df = investpy.get_historical_data(equity=random_equity, | |
start='01/01/2010', | |
end='01/01/2019', | |
as_json=False, | |
order='ascending') | |
print(historical_df.head()) | |
# The Company Profile from an equity can also be retrieved using investpy, | |
# the equity name to retrieve the data from and the language (spanish or english) | |
# need to be specified as it follows. | |
company_profile = investpy.get_equity_company_profile(equity=selected_equity, language='english') | |
pprint(company_profile) | |
# For any further information or advice feel free to email me at: [email protected] | |
# and if needed, open an issue in: https://github.com/alvarob96/investpy/issues |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment