Skip to main content

investpy — a Python package for financial historical data extraction from Investing

Project description

investpy — a Python package for financial historical data extraction from Investing

Python Version PyPi Version Anaconda Cloud Version Package Status Build Status Build Status Documentation Status codecov Downloads


Introduction

investpy is a Python package to retrieve real-time historical data from Investing. It provides historical data retrieval from up to 28.121 equities, 4.120 funds, 8.755 etfs and 385 indices. Basically, it allows you to download historical data from all the indexed equities, funds and etfs in Investing.com. Therefore, investpy is intended to wrap up all the available data from Investing, so that it can be retrieved via Python for its further usage and/or analysis.

investpy seeks to be one of the most complete Python packages when it comes to historical data extraction of financial products in order to stop relying on public/private APIs, as investpy is FREE and has NO LIMITATIONS. These are some of the features that currently lead investpy to be one of the most consistent packages of financial data retrieval.

Installation

In order to get this package working you will need to install investpy using pip on the terminal by typing:

$ pip install investpy==0.9.5

Every package used is listed in requirements.txt file, which can also be installed via pip:

$ pip install -r requirements.txt

Usage

Even though some investpy usage examples are shown on the docs, some basic functionality will be sorted out with sample Python code blocks.

Recent/Historical Data

As the main functionality is based on historical data retrieval, the usage of every function will be explained so to ease the user the use of investpy, which is mainly intended for historical data extraction, which means that every other function is additional.

Equity Data Retrieval

import investpy

df = investpy.get_recent_data(equity='bbva',
                              country='spain')
print(df.head())
             Open   High    Low  Close    Volume Currency
Date                                                     
2019-08-13  4.263  4.395  4.230  4.353  27250000      EUR
2019-08-14  4.322  4.325  4.215  4.244  36890000      EUR
2019-08-15  4.281  4.298  4.187  4.234  21340000      EUR
2019-08-16  4.234  4.375  4.208  4.365  46080000      EUR
2019-08-19  4.396  4.425  4.269  4.269  18950000      EUR
import investpy

df = investpy.get_historical_data(equity='bbva',
                                  country='spain',
                                  from_date='01/01/2010',
                                  to_date='01/01/2019')
print(df.head())
             Open   High    Low  Close  Volume Currency
Date                                                   
2010-01-04  12.73  12.96  12.73  12.96       0      EUR
2010-01-05  13.00  13.11  12.97  13.09       0      EUR
2010-01-06  13.03  13.17  13.02  13.12       0      EUR
2010-01-07  13.02  13.11  12.93  13.05       0      EUR
2010-01-08  13.12  13.22  13.04  13.18       0      EUR

Fund Data Retrieval

import investpy

df = investpy.get_fund_recent_data(fund='bbva plan multiactivo moderado pp',
                                   country='spain')
print(df.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
import investpy

df = investpy.get_fund_historical_data(fund='bbva plan multiactivo moderado pp',
                                       country='spain',
                                       from_date='01/01/2010',
                                       to_date='01/01/2019')
print(df.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

ETF Data Retrieval

import investpy

df = investpy.get_etf_recent_data(etf='bbva accion dj eurostoxx 50',
                                  country='spain')
print(df.head())
              Open    High     Low   Close Currency
Date                                               
2019-08-13  33.115  33.780  32.985  33.585      EUR
2019-08-14  33.335  33.335  32.880  32.905      EUR
2019-08-15  32.790  32.925  32.455  32.845      EUR
2019-08-16  33.115  33.200  33.115  33.305      EUR
2019-08-19  33.605  33.735  33.490  33.685      EUR
import investpy

df = investpy.get_etf_historical_data(etf='bbva accion dj eurostoxx 50',
                                      country='spain',
                                      from_date='01/01/2018',
                                      to_date='01/01/2019')
print(df.head())
             Open   High    Low  Close Currency
Date                                           
2011-12-07  23.70  23.70  23.70  23.62      EUR
2011-12-08  23.53  23.60  23.15  23.04      EUR
2011-12-09  23.36  23.60  23.36  23.62      EUR
2011-12-12  23.15  23.26  23.00  22.88      EUR
2011-12-13  22.88  22.88  22.88  22.80      EUR

Index Data Retrieval

import investpy

df = investpy.get_index_recent_data(index='ibex 35',
                                    country='spain')
print(df.head())
               Open     High      Low    Close   Volume Currency
Date
2019-08-26  12604.7  12646.3  12510.4  12621.3  4770000      EUR
2019-08-27  12618.3  12723.3  12593.6  12683.8  8230000      EUR
2019-08-28  12657.2  12697.2  12585.1  12642.5  7300000      EUR
2019-08-29  12637.2  12806.6  12633.8  12806.6  5650000      EUR
2019-08-30  12767.6  12905.9  12756.9  12821.6  6040000      EUR
import investpy

df = investpy.get_index_historical_data(index='ibex 35',
                                        country='spain',
                                        from_date='01/01/2018',
                                        to_date='01/01/2019')
print(df.head())
               Open     High      Low    Close    Volume Currency
Date
2018-01-02  15128.2  15136.7  14996.6  15096.8  10340000      EUR
2018-01-03  15145.0  15186.9  15091.9  15106.9  12800000      EUR
2018-01-04  15105.5  15368.7  15103.7  15368.7  17070000      EUR
2018-01-05  15353.9  15407.5  15348.6  15398.9  11180000      EUR
2018-01-08  15437.1  15448.7  15344.0  15373.3  12890000      EUR

Additional Data

As Investing provides more data besides the historical one, some of that additional data can be fetched via investpy. Currently, as the package is under-development, some additional information such as company profiles or inner basic information is retrieved for both equities and funds, respectively as shown below.

Equity Company Profile Retrieval

import investpy

company_profile = investpy.get_equity_company_profile(equity='bbva',
                                                      country='spain')
print(company_profile)
"Banco Bilbao Vizcaya Argentaria, S.A. (BBVA) is a diversified financial company engaged in retail banking ..."

Fund Additional Information Retrieval

import investpy

fund_information = investpy.get_fund_information(fund='bbva plan multiactivo moderado pp',
                                                 country='spain',
                                                 as_json=True)
print(fund_information)
{
 'Fund Name': 'Bbva Plan Multiactivo Moderado Pp',
 'Rating': 4,
 '1-Year Change': '-1,19%',
 'Previous Close': '1.103',
 'Risk Rating': 1,
 'TTM Yield': '0%',
 'ROE': '14,02%',
 'Issuer': 'BBVA Pensiones EGFP',
 'Turnover': None,
 'ROA': '4,97%',
 'Inception Date': '16/10/2012',
 'Total Assets': 1670000000,
 'Expenses': None,
 'Min Investment': 30,
 'Market Cap': 34820000000,
 'Category': 'Mixtos Euros Moderados PP'
}

Contribute - Open Source Helpers

As this is an open source project it is open to contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas.

Also there is an open tab of issues where anyone can contribute opening new issues if needed or navigate through them in order to solve them or contribute to its solving.

Additionally, you can triage issues on investpy CodeTriage so you can provide issues so the package can grow and improve as the issues solves bugs, problems or needs, and maybe provide new ideas to improve package functionality and efficiency.

Disclaimer

This Python package has been made for research purposes in order to fit the needs that Investing.com does not cover, so this package works like an Application Programming Interface (API) of Investing.com developed in an altruistic way. Conclude that this package is not related in any way with Investing.com or any dependant company, the only requirement specified by Investing in order to develop this package was "mention the source where data is retrieved from".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

investpy-0.9.5.tar.gz (1.2 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page