def test_investpy_etfs(): """ This function checks that etf data retrieval functions listed in investpy work properly. """ params = [ { 'country': 'spain', }, { 'country': None, }, ] for param in params: investpy.get_etfs(country=param['country']) investpy.get_etfs_list(country=param['country']) params = [ { 'country': None, 'columns': ['name'], 'as_json': True }, { 'country': None, 'columns': ['name'], 'as_json': False }, { 'country': 'spain', 'columns': ['name'], 'as_json': True }, { 'country': 'spain', 'columns': ['name'], 'as_json': False }, { 'country': 'spain', 'columns': None, 'as_json': False }, ] for param in params: investpy.get_etfs_dict(country=param['country'], columns=param['columns'], as_json=param['as_json']) investpy.get_etf_countries() params = [ { 'as_json': True, 'order': 'ascending', }, { 'as_json': False, 'order': 'ascending', }, { 'as_json': True, 'order': 'descending', }, { 'as_json': False, 'order': 'descending', }, ] for param in params: investpy.get_etf_recent_data(etf='bbva accion dj eurostoxx 50', country='spain', as_json=param['as_json'], order=param['order'], interval='Daily') investpy.get_etf_historical_data(etf='bbva accion dj eurostoxx 50', country='spain', from_date='01/01/2010', to_date='01/01/2019', as_json=param['as_json'], order=param['order'], interval='Daily') params = [ { 'etf': 'bbva accion dj eurostoxx 50', 'country': 'spain', 'as_json': False }, { 'etf': 'bbva accion dj eurostoxx 50', 'country': 'spain', 'as_json': True } ] for param in params: investpy.get_etf_information(etf=param['etf'], country=param['country'], as_json=param['as_json']) params = [ { 'country': 'united states', 'as_json': True, 'n_results': 2 }, { 'country': 'united kingdom', 'as_json': False, 'n_results': 2 }, ] for param in params: investpy.get_etfs_overview(country=param['country'], as_json=param['as_json'], n_results=param['n_results']) investpy.search_etfs(by='name', value='bbva')
def test_investpy_etfs(): """ This function checks that etf data retrieval functions listed in investpy work properly. """ params = [ { 'country': 'spain', }, { 'country': None, }, ] for param in params: investpy.get_etfs(country=param['country']) investpy.get_etfs_list(country=param['country']) params = [ { 'country': None, 'columns': ['id', 'name'], 'as_json': True }, { 'country': None, 'columns': ['id', 'name'], 'as_json': False }, { 'country': 'spain', 'columns': ['id', 'name'], 'as_json': True }, { 'country': 'spain', 'columns': ['id', 'name'], 'as_json': False }, { 'country': 'spain', 'columns': None, 'as_json': False }, ] for param in params: investpy.get_etfs_dict(country=param['country'], columns=param['columns'], as_json=param['as_json']) investpy.get_etf_countries() params = [ { 'as_json': True, 'order': 'ascending', 'debug': False }, { 'as_json': False, 'order': 'ascending', 'debug': True }, { 'as_json': True, 'order': 'descending', 'debug': False }, { 'as_json': False, 'order': 'descending', 'debug': False }, ] for param in params: investpy.get_etf_recent_data(etf='bbva accion dj eurostoxx 50', country='spain', as_json=param['as_json'], order=param['order'], debug=param['debug']) investpy.get_etf_historical_data(etf='bbva accion dj eurostoxx 50', country='spain', from_date='01/01/2010', to_date='01/01/2019', as_json=param['as_json'], order=param['order'], debug=param['debug']) params = [ { 'country': 'france', 'as_json': True, }, { 'country': 'france', 'as_json': False, }, ] for param in params: investpy.get_etfs_overview(country=param['country'], as_json=param['as_json']) investpy.search_etfs(by='name', value='bbva')
def test_investpy(): """ This function checks that main functions of investpy work properly. """ investpy.get_equities() investpy.get_equities_list() params = [ {'as_json': False, 'order': 'ascending'}, {'as_json': True, 'order': 'descending'}, {'as_json': True, 'order': 'ascending'}, {'as_json': False, 'order': 'descending'}, ] for param in params: investpy.get_recent_data(equity='enagás', as_json=param['as_json'], order=param['order']) investpy.get_historical_data(equity='enagás', start='01/01/1990', end='01/01/2019', as_json=param['as_json'], order=param['order']) for value in ['spanish', 'english']: investpy.get_equity_company_profile(equity='enagás', language=value) retrieve_equities() investpy.get_funds() investpy.get_funds_list() for value in [True, False]: investpy.get_funds_dict(columns=['id', 'name'], as_json=value) investpy.get_fund_information(fund='bbva multiactivo conservador pp', as_json=value) params = [ {'as_json': False, 'order': 'ascending'}, {'as_json': True, 'order': 'descending'}, {'as_json': True, 'order': 'ascending'}, {'as_json': False, 'order': 'descending'}, ] for param in params: investpy.get_fund_recent_data(fund='bbva multiactivo conservador pp', as_json=param['as_json'], order=param['order']) investpy.get_fund_historical_data(fund='bbva multiactivo conservador pp', start='01/01/2010', end='01/01/2019', as_json=param['as_json'], order=param['order']) investpy.get_funds() retrieve_funds() investpy.get_etfs() investpy.get_etf_countries() for value in ['spain', None]: investpy.get_etf_df(country=value) investpy.get_etf_list(country=value) params = [ {'country': None, 'columns': ['id', 'name'], 'as_json': False}, {'country': None, 'columns': ['id', 'name'], 'as_json': True}, {'country': 'spain', 'columns': None, 'as_json': False}, {'country': 'spain', 'columns': ['id', 'name'], 'as_json': True}, ] for param in params: investpy.get_etf_dict(country=param['country'], columns=param['columns'], as_json=param['as_json']) params = [ {'as_json': False, 'order': 'ascending'}, {'as_json': True, 'order': 'descending'}, {'as_json': True, 'order': 'ascending'}, {'as_json': False, 'order': 'descending'}, ] for param in params: investpy.get_etf_recent_data(etf='bbva accion dj eurostoxx 50', as_json=param['as_json'], order=param['order']) investpy.get_etf_historical_data(etf='bbva accion dj eurostoxx 50', start='01/01/2010', end='01/01/2019', as_json=param['as_json'], order=param['order']) retrieve_etfs()
def test_investpy(): """ This function checks that main functions of investpy work properly. """ print(investpy.__author__, investpy.__version__) for value in ['spain', None]: investpy.get_equities(country=value) investpy.get_equities_list(country=value) params = [ { 'country': None, 'columns': ['id', 'name'], 'as_json': True }, { 'country': 'spain', 'columns': ['id', 'name'], 'as_json': True }, { 'country': None, 'columns': ['id', 'name'], 'as_json': False }, { 'country': 'spain', 'columns': None, 'as_json': False }, { 'country': 'spain', 'columns': ['id', 'name'], 'as_json': False }, ] for param in params: investpy.get_equities_dict(country=param['country'], columns=param['columns'], as_json=param['as_json']) investpy.get_equity_countries() params = [ { 'as_json': False, 'order': 'ascending', 'debug': True }, { 'as_json': True, 'order': 'descending', 'debug': False }, { 'as_json': True, 'order': 'ascending', 'debug': False }, { 'as_json': False, 'order': 'descending', 'debug': False }, ] for param in params: investpy.get_recent_data(equity='enagás', country='spain', as_json=param['as_json'], order=param['order'], debug=param['debug']) investpy.get_historical_data(equity='enagás', country='spain', from_date='01/01/1990', to_date='01/01/2019', as_json=param['as_json'], order=param['order'], debug=param['debug']) for value in ['spanish', 'english']: investpy.get_equity_company_profile(equity='enagás', country='spain', language=value) retrieve_equities(test_mode=True) retrieve_equity_countries(test_mode=True) params = [ { 'country': 'spain', }, { 'country': None, }, ] for param in params: investpy.get_funds(country=param['country']) investpy.get_funds_list(country=param['country']) params = [ { 'country': None, 'columns': ['id', 'name'], 'as_json': True }, { 'country': 'spain', 'columns': ['id', 'name'], 'as_json': True }, { 'country': None, 'columns': ['id', 'name'], 'as_json': False }, { 'country': 'spain', 'columns': None, 'as_json': False }, { 'country': 'spain', 'columns': ['id', 'name'], 'as_json': False }, ] for param in params: investpy.get_funds_dict(country=param['country'], columns=param['columns'], as_json=param['as_json']) params = [ { 'fund': 'bbva multiactivo conservador pp', 'country': 'spain', 'as_json': True, }, { 'fund': 'bbva multiactivo conservador pp', 'country': 'spain', 'as_json': False, }, ] for param in params: investpy.get_fund_information(fund=param['fund'], country=param['country'], as_json=param['as_json']) params = [ { 'as_json': False, 'order': 'ascending', 'debug': True }, { 'as_json': True, 'order': 'descending', 'debug': False }, { 'as_json': True, 'order': 'ascending', 'debug': False }, { 'as_json': False, 'order': 'descending', 'debug': False }, ] for param in params: investpy.get_fund_recent_data(fund='bbva multiactivo conservador pp', country='spain', as_json=param['as_json'], order=param['order'], debug=param['debug']) investpy.get_fund_historical_data( fund='bbva multiactivo conservador pp', country='spain', from_date='01/01/2010', to_date='01/01/2019', as_json=param['as_json'], order=param['order'], debug=param['debug']) investpy.get_fund_countries() investpy.get_funds() retrieve_funds(test_mode=True) retrieve_fund_countries(test_mode=True) investpy.get_etf_countries() for value in ['spain', None]: investpy.get_etfs(country=value) investpy.get_etfs_list(country=value) params = [ { 'country': None, 'columns': ['id', 'name'], 'as_json': True }, { 'country': 'spain', 'columns': ['id', 'name'], 'as_json': True }, { 'country': None, 'columns': ['id', 'name'], 'as_json': False }, { 'country': 'spain', 'columns': None, 'as_json': False }, { 'country': 'spain', 'columns': ['id', 'name'], 'as_json': False }, ] for param in params: investpy.get_etfs_dict(country=param['country'], columns=param['columns'], as_json=param['as_json']) params = [ { 'as_json': False, 'order': 'ascending', 'debug': True }, { 'as_json': True, 'order': 'descending', 'debug': False }, { 'as_json': True, 'order': 'ascending', 'debug': False }, { 'as_json': False, 'order': 'descending', 'debug': False }, ] for param in params: investpy.get_etf_recent_data(etf='bbva accion dj eurostoxx 50', country='spain', as_json=param['as_json'], order=param['order'], debug=param['debug']) investpy.get_etf_historical_data(etf='bbva accion dj eurostoxx 50', country='spain', from_date='01/01/2010', to_date='01/01/2019', as_json=param['as_json'], order=param['order'], debug=param['debug']) params = [ { 'country': 'france', 'as_json': True, }, { 'country': 'usa', 'as_json': False, }, ] for param in params: investpy.get_etfs_overview(country=param['country'], as_json=param['as_json']) retrieve_etfs(test_mode=True)
fund_sheet = 'funds' index_sheet = 'indices' stock_sheet = 'stocks' bond_sheet = 'bonds' etf_sheet = 'etfs' crypto_sheet = 'cryptos' req_fund_countries = investpy.get_fund_countries() df_fund_countries = pd.DataFrame(req_fund_countries) req_bond_countries = investpy.get_bond_countries() df_bond_countries = pd.DataFrame(req_bond_countries) req_index_countries = investpy.get_index_countries() df_index_countries = pd.DataFrame(req_index_countries) req_stock_countries = investpy.get_stock_countries() df_stock_countries = pd.DataFrame(req_stock_countries) req_etf_countries = investpy.get_etf_countries() df_etf_countries = pd.DataFrame(req_etf_countries) def GetCountries(): wb = xw.Book.caller() wb.sheets[fund_sheet].range('A1').value = df_fund_countries wb.sheets[index_sheet].range('A1').value = df_index_countries wb.sheets[stock_sheet].range('A1').value = df_stock_countries wb.sheets[bond_sheet].range('A1').value = df_bond_countries wb.sheets[etf_sheet].range('A1').value = df_etf_countries