def test_investpy_commodities(): """ This function checks that commodity data retrieval functions listed in investpy work properly. """ params = [ { 'group': 'metals', }, { 'group': None, }, ] for param in params: investpy.get_commodities(group=param['group']) investpy.get_commodities_list(group=param['group']) params = [ { 'group': None, 'columns': ['title', 'full_name', 'name'], 'as_json': True }, { 'group': None, 'columns': ['title', 'full_name', 'name'], 'as_json': False }, { 'group': 'metals', 'columns': ['title', 'full_name', 'name'], 'as_json': True }, { 'group': 'metals', 'columns': ['title', 'full_name', 'name'], 'as_json': False }, { 'group': 'metals', 'columns': None, 'as_json': False }, ] for param in params: investpy.get_commodities_dict(group=param['group'], columns=param['columns'], as_json=param['as_json']) investpy.get_commodity_groups() params = [ { 'country': None, 'as_json': True, 'order': 'ascending', }, { 'country': 'united states', 'as_json': False, 'order': 'ascending', }, { 'country': 'united states', 'as_json': True, 'order': 'descending', }, { 'country': 'united states', 'as_json': False, 'order': 'descending', }, ] for param in params: investpy.get_commodity_recent_data(commodity='copper', country=param['country'], as_json=param['as_json'], order=param['order'], interval='Daily') investpy.get_commodity_historical_data(commodity='copper', from_date='01/01/1990', to_date='01/01/2019', country=param['country'], as_json=param['as_json'], order=param['order'], interval='Daily') params = [ { 'commodity': 'copper', 'country': None, 'as_json': False }, { 'commodity': 'copper', 'country': 'united states', 'as_json': True } ] for param in params: investpy.get_commodity_information(commodity=param['commodity'], country=param['country'], as_json=param['as_json']) params = [ { 'group': 'metals', 'as_json': True, 'n_results': 100 }, { 'group': 'metals', 'as_json': False, 'n_results': 100 } ] for param in params: investpy.get_commodities_overview(group=param['group'], as_json=param['as_json'], n_results=param['n_results']) investpy.search_commodities(by='name', value='gold')
investpy_KRXENER = investpy.get_index_historical_data( index="KRX Energy & Chemical", country="south korea", from_date="30/01/1900", to_date=DD_END_DATE) investpy_KRXENER.to_pickle('./Market_Watch_Data/investpy_KRXENER.pkl') # KTB (2014.05.19 부터) investpy_KTB = investpy.get_index_historical_data(index="KTB", country="south korea", from_date="30/01/1900", to_date=DD_END_DATE) investpy_KTB.to_pickle('./Market_Watch_Data/investpy_KTB.pkl') ######################################################################################################################## investpy.get_commodities_list() # Gold Futures (ZGJ2) investpy_Gold = investpy.get_commodity_historical_data(commodity="Gold", from_date="30/01/1900", to_date=DD_END_DATE, country=None, as_json=False, order='ascending', interval='Daily') investpy_Gold.to_pickle('./Market_Watch_Data/investpy_Gold.pkl') ######################################################################################################################## # Bitcoin investpy_bitcoin = investpy.get_crypto_historical_data(crypto='bitcoin', from_date="30/01/1900",