FinanceDatabase Guide – A Comprehensive Database of Financial Symbols (Python Package)

5 min read

Get 10-day Free Algo Trading Course

Loading

Last Updated on May 10, 2023

Table of contents:

  1. What is FinanceDatabase?
  2. What is FinanceDatabase used for?
  3. Why should I use FinanceDatabase?
  4. Why shouldn’t I use FinanceDatabase?
  5. Is FinanceDatabase free?
  6. What are some FinanceDatabase alternatives?
  7. What kind of data does FinanceDatabase have?
  8. How to get started with FinanceDatabase?
  9. How to get general data with FinanceDatabase?
  10. How to perform an advanced search on the FinanceDatabase?
  11. How to collect data from the FinanceDatabase?
  12. How to obtain all US companies from different sectors using the FinanceDatabase?
  13. How to perform technical analysis with FInanceDatabase?
  14. How to store the FinanceDatabase in a different location?
  15. Where can I learn more about the FinanceDatabase?
  16. Full code

What is FinanceDatabase?

FinanceDatabase is a Python package of 300.000+ symbols containing Equities, ETFs, Funds, Indices, Currencies, Cryptocurrencies, and Money Markets.

Link: https://pypi.org/project/financedatabase/

What is FinanceDatabase used for?

FinanceDatabase is mainly used for any type of financial product categorization. Moreover, it gives insights into the products that exist in each country, industry, and sector and gives the most essential information about each product.

This allows algorithmic traders and investors to analyze specific financial segments and helps them find assets that are hard to uncover. For example, it is used within the OpenBB terminal.

Why should I use FinanceDatabase?

  • The FinanceDatabase is comprehensive.
  • The FinanceDatabase has over 300k assets.
  • It is easy to use and beginner friendly.
  • It is open-sourced.
  • Has good filtering capabilities.
  • Is actively maintained.

Why shouldn’t I use FinanceDatabase?

  • The FinanceDatabase doesn’t provide up-to-date fundamentals or stock data (it doesn’t have that goal).
  • The FinanceDatabase doesn’t hold all possible assets.
  • It is maintained by an open-source community so some information might be outdated.

Is FinanceDatabase free?

Yes, FinanceDatabase is open-sourced and thus it is completely free.

What are some FinanceDatabase alternatives?

The FinanceDatabase doesn’t have direct alternatives but some of them are:

  • Marketstack
  • MarketWatch
  • Bloomberg Terminal
  • Quandl

What kind of data does FinanceDatabase have?

FinanceDatabase has approximately the following kind of data:

Product Quantity Sectors Industries Countries Exchanges
Equities 155.705 16 242 111 82
ETFs 36.727 364* 94* 100** 52
Funds 57.816 1678* 438* 100** 34
Product Quantity Category
Currencies 2.590 174 Currencies
Cryptocurrencies 3.624 299 Cryptocurrencies
Indices 86.353 49 Exchanges
Money Markets 1.384 2 Exchanges

How to get started with FinanceDatabase?

To get started with FinanceDatabase, you will need to install its Python library with the following command:

pip install financedatabase

In the following article sections, we will explore what the FinanceDatabase has to offer and how it can be used for conducting financial research.

import financedatabase as fd

How to get general data with FinanceDatabase?

To get general data with FinanceDatabase, you will need to initialize the part of the database you want to use (e.g. equities) and use the filtering methods such as options, select and search.

For example, let’s initialize the equities database and obtain all industries from a specific country:

equities = fd.Equities()

equities_germany_industries = equities.options('industry', country='Singapore')
equities_germany_industries
array(['Aerospace & Defense', 'Air Freight & Logistics', 'Airlines',
       'Auto Components', 'Automobiles', 'Banks', 'Beverages', ...

We obtain all of the 55 industries in Singapore, feel free to experiment with other countries.

Now, let’s obtain all equities from a specific country such as the USA:

equities_united_states = equities.select(country="United States")
equities_united_states.head()

How to perform an advanced search on the FinanceDatabase?

To perform an advanced search on the Finance Databse, you can use the search method and pass multiple parameters to limit your search to a specific market segment.

For example, let’s obtain all Swedish software companies that have the word “cloud” in their summary and are part of the FRA exchange:

equities_sweden_software = equities.search(
    country='Sweden',
    industry='Software',
    summary="cloud",
    exchange="FRA"
)
equities_sweden_software

Feel free to try out other industries, sectors, and parameters to filter on.

How to collect data from the FinanceDatabase?

To collect data from the FinanceDatabase, you can initialize a specific part of it (e.g. Equities, Indices, Funds, etc.) and perform a .select() to obtain all available information. For example, let’s obtain all indices:

indices = fd.Indices()
indices.select()

How to obtain all US companies from different sectors using the FinanceDatabase?

To obtain all US companies from different sectors using the FinanceDatabase, you can utilize the options and select features to loop over all the sectors and aggregate the companies per each of them.

equities_sectors_us = {}

for sector in equities.options(selection='sector', country='United States'):
    try:
        equities_sectors_us[sector] = len(equities.select(country='United States', sector=sector))
    except ValueError as error:
        print(error)
{'Communication Services': 444,
 'Consumer Discretionary': 739,
 'Consumer Staples': 402,
 'Energy': 470,
 'Financials': 3919,
 'Health Care': 1559,
 'Industrials': 1044,
 'Information Technology': 1043,
 'Materials': 424,
 'Real Estate': 513,
 'Utilities': 190}

How to perform technical analysis with FinanceDatabase?

To perform technical analysis with FinanceDatabase, you will need to extend its features with other libraries such as yfinance, ta, talib, and similar. For example, let’s examine the french wine industry’s large caps in a post-covid market setting.

The first thing that we want to do is to install the libraries that are missing:

!pip install ta
!pip install yfinance

Now, we import everything that we’ll be using:

import pandas as pd
import yfinance as yf
from ta.volatility import BollingerBands
import matplotlib.pyplot as plt
%matplotlib inline

The next step that we want to do is to obtain all the french beverage industry equities that have “wine” inside their summary and that are large caps. We will obtain the data from Match 2020 up to the beginning of 2023:

french_wine_equities = equities.search(
    country="France",
    industry="Beverages",
    summary="wine",
    market_cap="Large Cap"
)
french_wine_equities

From the output, we can observe that Pernod Ricard SA is the main and only leader here. Now, let’s obtain the data on these tickers with yfinance to examine them further:

tickers = list(french_wine_equities.index)

stock_fr_wine = yf.download(tickers, start="2020-03-01", end="2023-01-01")['Adj Close']
stock_fr_wine.drop(["PER1.F", "PDRDY"], axis=1, inplace=True)
stock_fr_wine.head()

As yfinance didn’t have the two tickers above, I removed them. Now, we will fill in the missing data and calculate the difference between the daily returns as I’d like to examine the difference in volatility, if any, between these tickers:

stock_fr_wine.fillna(method = 'ffill', inplace = True)
stock_fr_wine = stock_fr_wine.diff()

Now, I’ll add a Bollinger Bands indicator to help us gauge the volatility between the returns and only plot the upper and lower band. I’ll also add a straight line on the 0 y-axes.

fig, axis = plt.subplots(3, 2)
row = 0
column = 0

for ticker in stock_fr_wine.columns:
    data_plot = pd.DataFrame(stock_fr_wine[ticker])

    indicator_bb = BollingerBands(close=stock_fr_wine[ticker], window=20, window_dev=2)

    data_plot['bb_bbh'] = indicator_bb.bollinger_hband()
    data_plot['bb_bbl'] = indicator_bb.bollinger_lband()

    axis[row, column].plot(data_plot)
    axis[row, column].set_title(ticker, fontsize=16)
    axis[row, column].axhline(0, c="purple")

    column += 1
    if column == 2:
        row += 1
        column = 0
        
fig.suptitle('Technical Analysis of Pernod Ricard SA')
fig.set_size_inches(18.5, 10.5)
fig.tight_layout()

As you can see, there are differences in volatility between these assets and their respective exchanges. Knowing this, a trading strategy pattern or investment plan might start to sprout. Feel free to extend this simple analysis and try out other assets.

How to store the FinanceDatabase in a different location?

To store the FinanceDatabase in a different location, for example, your own fork of the repository, you can do so with the variablebase_url which can be found in each of the asset classes.

fd.Equities(base_url=<YOUR URL>)

You can also store the database locally and point to your local location with the variable base_url and by settinguse_local_location to True. For example:

fd.Equities(base_url=<YOUR PATH>, use_local_location=True)

Where can I learn more about the FinanceDatabase?

To learn more about the FinanceDatabase, I advise checking out its GitHub repository. You can also find this Jupyter Notebook of examples useful.

Full Code

GitHub link

Igor Radovanovic