investpy.fundsΒΆ

investpy.funds.get_fund_countries()ΒΆ

This function retrieves all the country names indexed in Investing.com with available funds to retrieve data from, via reading the fund_countries.csv file from the resources directory. So on, this function will display a listing containing a set of countries, in order to let the user know which countries are taken into account and also the return listing from this function can be used for country param check if needed.

Returns

The resulting list contains all the available countries with funds as indexed in Investing.com

Return type

list - countries

Raises
  • FileNotFoundError – raised when the fund_countries.csv file was not found.

  • IndexError – raised if fund_countries.csv file was unavailable or not found.

investpy.funds.get_fund_historical_data(fund, country, from_date, to_date, as_json=False, order='ascending', interval='Daily')ΒΆ

This function retrieves historical data from the introduced fund from Investing via Web Scraping on the introduced date range. The resulting data can it either be stored in a pandas.DataFrame or in a json object with ascending or descending order.

Parameters
  • fund (str) – name of the fund to retrieve recent historical data from.

  • country (str) – name of the country from where the introduced fund is.

  • from_date (str) – date as str formatted as dd/mm/yyyy, from where data is going to be retrieved.

  • to_date (str) – date as str formatted as dd/mm/yyyy, until where data is going to be retrieved.

  • as_json (bool, optional) – to determine the format of the output data (pandas.DataFrame or json).

  • order (str, optional) – optional argument to define the order of the retrieved data (ascending, asc or descending, desc).

  • interval (str, optional) – value to define the historical data interval to retrieve, by default Daily, but it can also be Weekly or Monthly.

Returns

The function returns a either a pandas.DataFrame or a json file containing the retrieved recent data from the specified fund via argument. The dataset contains the open, high, low and close values for the selected fund on market days.

The returned data is case we use default arguments will look like:

Date || Open | High | Low | Close | Currency
-----||------|------|-----|-------|----------
xxxx || xxxx | xxxx | xxx | xxxxx | xxxxxxxx

but if we define as_json=True, then the output will be:

{
    name: name,
    historical: [
        {
            date: dd/mm/yyyy,
            open: x,
            high: x,
            low: x,
            close: x,
            currency: x
        },
        ...
    ]
}

Return type

pandas.DataFrame or json

Raises
  • ValueError – argument error.

  • IOError – funds object/file not found or unable to retrieve.

  • RuntimeError – introduced fund does not match any of the indexed ones.

  • ConnectionError – if GET requests does not return 200 status code.

  • IndexError – if fund information was unavailable or not found.

Examples

>>> data = investpy.get_fund_historical_data(fund='bbva multiactivo conservador pp', country='spain', from_date='01/01/2010', to_date='01/01/2019')
>>> data.head()
             Open   High    Low  Close Currency
Date
2018-02-15  1.105  1.105  1.105  1.105      EUR
2018-02-16  1.113  1.113  1.113  1.113      EUR
2018-02-17  1.113  1.113  1.113  1.113      EUR
2018-02-18  1.113  1.113  1.113  1.113      EUR
2018-02-19  1.111  1.111  1.111  1.111      EUR
investpy.funds.get_fund_information(fund, country, as_json=False)ΒΆ

This function retrieves basic financial information from the specified fund. Retrieved information from the fund can be valuable as it is additional information that can be used combined with OHLC values, so to determine financial insights from the company which holds the specified fund.

Parameters
  • fund (str) – name of the fund to retrieve the financial information from.

  • country (str) – name of the country from where the introduced fund is.

  • as_json (bool, optional) – optional argument to determine the format of the output data (dict or json).

Returns

The resulting pandas.DataFrame contains the information fields retrieved from Investing.com from the specified fund; it can also be returned as a dict, if argument as_json=True.

If any of the information fields could not be retrieved, that field/s will be filled with None values. If the retrieval process succeeded, the resulting dict will look like:

fund_information = {
    'Fund Name': fund_name,
    'Rating': rating,
    '1-Year Change': year_change,
    'Previous Close': prev_close,
    'Risk Rating': risk_rating,
    'TTM Yield': ttm_yield,
    'ROE': roe,
    'Issuer': issuer,
    'Turnover': turnover,
    'ROA': row,
    'Inception Date': inception_date,
    'Total Assets': total_assets,
    'Expenses': expenses,
    'Min Investment': min_investment,
    'Market Cap': market_cap,
    'Category': category
}

Return type

pandas.DataFrame or dict- fund_information

investpy.funds.get_fund_recent_data(fund, country, as_json=False, order='ascending', interval='Daily')ΒΆ

This function retrieves recent historical data from the introduced fund from Investing via Web Scraping. The resulting data can it either be stored in a pandas.DataFrame or in a json file, with ascending or descending order.

Parameters
  • fund (str) – name of the fund to retrieve recent historical data from.

  • country (str) – name of the country from where the introduced fund is.

  • as_json (bool, optional) – optional argument to determine the format of the output data (pandas.DataFrame or json).

  • order (str, optional) – optional argument to define the order of the retrieved data (ascending, asc or descending, desc).

  • interval (str, optional) – value to define the historical data interval to retrieve, by default Daily, but it can also be Weekly or Monthly.

Returns

The function returns a either a pandas.DataFrame or a json file containing the retrieved recent data from the specified fund via argument. The dataset contains the open, high, low and close values for the selected fund on market days.

The returned data is case we use default arguments will look like:

Date || Open | High | Low | Close | Currency
-----||------|------|-----|-------|----------
xxxx || xxxx | xxxx | xxx | xxxxx | xxxxxxxx

but if we define as_json=True, then the output will be:

{
    name: name,
    recent: [
        {
            date: dd/mm/yyyy,
            open: x,
            high: x,
            low: x,
            close: x,
            currency: x
        },
        ...
    ]
}

Return type

pandas.DataFrame or json

Raises
  • ValueError – argument error.

  • IOError – funds object/file not found or unable to retrieve.

  • RuntimeError – introduced fund does not match any of the indexed ones.

  • ConnectionError – if GET requests does not return 200 status code.

  • IndexError – if fund information was unavailable or not found.

Examples

>>> data = investpy.get_fund_recent_data(fund='bbva multiactivo conservador pp', country='spain')
>>> data.head()
             Open   High    Low  Close Currency
Date
2019-08-13  1.110  1.110  1.110  1.110      EUR
2019-08-16  1.109  1.109  1.109  1.109      EUR
2019-08-19  1.114  1.114  1.114  1.114      EUR
2019-08-20  1.112  1.112  1.112  1.112      EUR
2019-08-21  1.115  1.115  1.115  1.115      EUR
investpy.funds.get_funds(country=None)ΒΆ

This function retrieves all the available funds from Investing.com and returns them as a pandas.DataFrame, which contains not just the fund names, but all the fields contained on the funds.csv file. All the available funds can be found at: https://www.investing.com/funds/

Parameters

country (str, optional) – name of the country to retrieve all its available funds from.

Returns

The resulting pandas.DataFrame contains all the funds basic information retrieved from Investing.com, some of which is not useful for the user, but for the inner package functions, such as the id field, for example.

In case the information was successfully retrieved, the pandas.DataFrame will look like:

country | name | symbol | issuer | isin | asset_class | currency | underlying
--------|------|--------|--------|------|-------------|----------|------------
xxxxxxx | xxxx | xxxxxx | xxxxxx | xxxx | xxxxxxxxxxx | xxxxxxxx | xxxxxxxxxx

Return type

pandas.DataFrame - funds_df

Raises
  • ValueError – raised whenever any of the introduced arguments is not valid or errored.

  • FileNotFoundError – raised when the funds.csv file was not found.

  • IOError – raised if the funds.csv file is missing or errored.

investpy.funds.get_funds_dict(country=None, columns=None, as_json=False)ΒΆ

This function retrieves all the available funds on Investing.com and returns them as a dict containing the country, name, symbol, tag, id, issuer, isin, asset_class, currency and underlying data. All the available funds can be found at: https://www.investing.com/funds/

Parameters
  • country (str, optional) – name of the country to retrieve all its available funds from.

  • columns (list of str, optional) – description a list containing the column names from which the data is going to be retrieved.

  • as_json (bool, optional) – description value to determine the format of the output data (dict or json).

Returns

The resulting dict contains the retrieved data if found, if not, the corresponding fields are filled with None values.

In case the information was successfully retrieved, the dict will look like:

{
    'country': country,
    'name': name,
    'symbol': symbol,
    'issuer': issuer,
    'isin': isin,
    'asset_class': asset_class,
    'currency': currency,
    'underlying': underlying
}

Return type

dict or json - funds_dict

Raises
  • ValueError – raised whenever any of the introduced arguments is not valid or errored.

  • FileNotFoundError – raised when the funds.csv file was not found.

  • IOError – raised if the funds.csv file is missing or errored.

investpy.funds.get_funds_list(country=None)ΒΆ

This function retrieves all the available funds and returns a list of each one of them. All the available funds can be found at: https://www.investing.com/funds/

Parameters

country (str, optional) – name of the country to retrieve all its available funds from.

Returns

The resulting list contains the retrieved data, which corresponds to the fund names of every fund listed on Investing.com.

In case the information was successfully retrieved from the CSV file, the list will look like:

funds = [
    'Blackrock Global Funds - Global Allocation Fund E2',
    'Quality InversiΓ³n Conservadora Fi',
    'Nordea 1 - Stable Return Fund E Eur',
    ...
]

Return type

list - funds_list

Raises
  • ValueError – raised whenever any of the introduced arguments is not valid or errored.

  • FileNotFoundError – raised when the funds.csv file was not found.

  • IOError – raised if the funds.csv file is missing or errored.

investpy.funds.get_funds_overview(country, as_json=False, n_results=100)ΒΆ

This function retrieves an overview containing all the real time data available for the main funds from a country, such as the names, symbols, current value, etc. as indexed in Investing.com. So on, the main usage of this function is to get an overview on the main funds from a country, so to get a general view. Note that since this function is retrieving a lot of information at once, by default just the overview of the Top 100 funds is being retrieved, but an additional parameter called n_results can be specified so to retrieve N results.

Parameters
  • country (str) – name of the country to retrieve the funds overview from.

  • as_json (bool, optional) – optional argument to determine the format of the output data (pandas.DataFrame or json).

  • n_results (int, optional) – number of results to be displayed on the overview table (0-1000).

Returns

The resulting pandas.DataFrame contains all the data available in Investing.com of the main ETFs from a country in order to get an overview of it.

If the retrieval process succeeded, the resulting pandas.DataFrame should look like:

country | name | symbol | last | change | total_assets
--------|------|--------|------|--------|--------------
xxxxxxx | xxxx | xxxxxx | xxxx | xxxxxx | xxxxxxxxxxxx

Return type

pandas.DataFrame - funds_overview

Raises
  • ValueError – raised if there was any argument error.

  • FileNotFoundError – raised when funds.csv file is missing.

  • IOError – raised if data could not be retrieved due to file error.

  • RuntimeError – raised either if the introduced country does not match any of the listed ones or if no overview results could be retrieved from Investing.com.

  • ConnectionError – raised if GET requests does not return 200 status code.

investpy.funds.search_funds(by, value)ΒΆ

This function searches funds by the introduced value for the specified field. This means that this function is going to search if there is a value that matches the introduced value for the specified field which is the funds.csv column name to search in. Available fields to search funds are β€˜name’, β€˜symbol’, β€˜issuer’ and β€˜isin’.

Parameters
  • by (str) – name of the field to search for, which is the column name (β€˜name’, β€˜symbol’, β€˜issuer’ or β€˜isin’).

  • value (str) – value of the field to search for, which is the str that is going to be searched.

Returns

The resulting pandas.DataFrame contains the search results from the given query (the specified value in the specified field). If there are no results and error will be raised, but otherwise this pandas.DataFrame will contain all the available field values that match the introduced query.

Return type

pandas.DataFrame - search_result

Raises
  • ValueError – raised if any of the introduced params is not valid or errored.

  • FileNotFoundError – raised if funds.csv file is missing.

  • IOError – raised if data could not be retrieved due to file error.

  • RuntimeError – raised if no results were found for the introduced value in the introduced field.