Ejemplo n.º 1
0
def test_investpy_indices():
    """
    This function checks that index data retrieval functions listed in investpy work properly.
    """

    params = [
        {
            'country': 'spain',
        },
        {
            'country': None,
        },
    ]

    for param in params:
        investpy.get_indices(country=param['country'])
        investpy.get_indices_list(country=param['country'])

    params = [
        {
            'country': None,
            'columns': ['name', 'currency'],
            'as_json': True
        },
        {
            'country': None,
            'columns': ['name', 'currency'],
            'as_json': False
        },
        {
            'country': 'spain',
            'columns': ['name', 'currency'],
            'as_json': True
        },
        {
            'country': 'spain',
            'columns': ['name', 'currency'],
            'as_json': False
        },
        {
            'country': 'spain',
            'columns': None,
            'as_json': False
        },
    ]

    for param in params:
        investpy.get_indices_dict(country=param['country'],
                                  columns=param['columns'],
                                  as_json=param['as_json'])

    investpy.get_index_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_index_recent_data(index='ibex 35',
                                       country='spain',
                                       as_json=param['as_json'],
                                       order=param['order'],
                                       interval='Daily')

        investpy.get_index_historical_data(index='ibex 35',
                                           country='spain',
                                           from_date='01/01/2018',
                                           to_date='01/01/2019',
                                           as_json=param['as_json'],
                                           order=param['order'],
                                           interval='Daily')

    params = [
        {
            'index': 'ibex 35',
            'country': 'spain',
            'as_json': False
        },
        {
            'index': 'ibex 35',
            'country': 'spain',
            'as_json': True
        }
    ]

    for param in params:
        investpy.get_index_information(index=param['index'], country=param['country'], as_json=param['as_json'])
    
    params = [
        {
            'country': 'united states', 
            'as_json': False,
            'n_results': 10
        },
        {
            'country': 'united kingdom', 
            'as_json': True,
            'n_results': 10
        }
    ]

    for param in params:
        investpy.get_indices_overview(country=param['country'], as_json=param['as_json'], n_results=param['n_results'])

    investpy.search_indices(by='name', value='ibex')
Ejemplo n.º 2
0
etf_sheet = 'etfs'
crypto_sheet = 'cryptos'
home_sheet = 'Home'

fund = xw.sheets[home_sheet].range('G3').value
index = xw.sheets[home_sheet].range('G4').value
stock = xw.sheets[home_sheet].range('G5').value
bond = xw.sheets[home_sheet].range('G6').value
etf = xw.sheets[home_sheet].range('G7').value

if fund and fund_country != "":
    req_fund_info = investpy.get_fund_information(fund=fund,
                                                  country=fund_country)

if index and index_country != "":
    req_index_info = investpy.get_index_information(index=index,
                                                    country=index_country)

if stock and stock_country != "":
    req_stock_info = investpy.get_stock_information(stock=stock,
                                                    country=stock_country)

if bond and bond_country != "":
    req_bond_info = investpy.get_bond_information(bond=bond)

if etf and etf_country != "":
    req_etf_info = investpy.get_etf_information(etf=etf, country=etf_country)


def GetFundInformation():
    wb = xw.Book.caller()
    wb.sheets[fund_sheet].range('N1').options(