avatarSlawomir Lisowski

Summary

This article discusses how to use fundamental data from the Financial Modeling Prep API to support algorithmic trading.

Abstract

The article encourages readers to explore additional data sources, such as fundamental data, to improve their algorithmic trading strategies. It introduces the Financial Modeling Prep API as a comprehensive source for financial and market data, and provides a Python module to download and convert this data into a pandas dataframe. The article demonstrates how to obtain general company information, financial statements, news, sentiment, and charts using the API. It emphasizes the importance of fundamental analysis and risk management in trading decisions.

Opinions

  • The author believes that using fundamental data can broaden the view on assets being traded and improve profits.
  • The author suggests that a mix of current fundamental data and traditional technical indicators can enhance trading algorithms.
  • The author recommends using the Financial Modeling Prep API for accessing financial and market data in one place.
  • The author highlights the importance of rating and recommendations for a company.
  • The author emphasizes the role of financial statements in fundamental analysis of a company.
  • The author acknowledges the influence of news and social media sentiment on trading decisions.
  • The author stresses the need for risk management in trading, regardless of the approach used.

Support your algorithmic trading with fundamental data

How to download fundamental data from Financial Modeling Prep API

Photo by Unsplash

In this article I would like to eager you to find other sources of data, that can broaden your view on assets which you are trading on.

In algorithmic trading we are focused only on price of instrument or volume, that instrument generate. Every technical analysis indicator is determined by price or volume of asset. Nowadays we have access to wide range of data sources from financial markets. Why don’t use this possibilites to improve our profits. Of course fundamental data , they are not distributed as often as price and volume of instrument. Sometimes time between two single trades is counted in minutes. But to improve our algorithm we can use mix of current fundamental data for given instrument and traditional technical indicators. So let’s see where find market and fundamental data, as well as download them in friendly format.

Financial Modeling Prep API

We can find many data sources with financial and market data but usually they are dispersed on different websites or advanced webscraping knowledge is required to get them. Financial Modeling Prep API let us find financial and market data in one place. I have prepared simple Python module FmpConnector.py to download data from FMP API and convert them to pandas df, so I will show you how to collect this data to use them in further analysis. For access to all endpoints from this tutorial, required is at least STARTER PLAN.

General information about company

Basic informations about company like industry and geographical location of business entity, allow us to compare it between other companies operating in the same industry or with the industry as a whole. Geolocation is important for example, when company is operating in legal environment for given region. Let’s see way to get most important information about company profile from Financial Modeling Prep API. First create account on https://site.financialmodelingprep.com/ and find your api key in Developers section.

from FmpConnector import FmpConnector

fmp_api=FmpConnector(YOUR_API_KEY)

Now it’s time to get info about company that we are interesting in.

msft_info_df=fmp_api.get_company_info(symbol='MSFT', info_type='company_profile')

As result we have dataframe with many basic information about Microsoft. If we care about rating or recommendations for company, that it is very simple to filter this info. Firstly rating …

msft_info_df=fmp_api.get_company_info(symbol='MSFT', info_type='company_rating')

And latest recommendations.

msft_info_df=fmp_api.get_company_info(symbol='MSFT', info_type='recommendations', limit=10)

Of course every detail about given method you can find in documentation of FmpConnector.py.

Financial statements

Fundamental analysis of company is based mostly on financial statements. Detailed analysis is possible when we have complete and structured data about financial condition of company.

help(fmp_api.get_financial_data)

Help on method get_financial_data in module FmpConnector:

get_financial_data(symbol, report_type='balance_statement', period='annual', limit=10, as_reported=False) method of FmpConnector.FmpConnector instance
    Description
    ============================================
    Return financial data, statements for given company from given period
    
    Parameters
    ============================================
    *symbol -> str
    report_type -> str{balance_statement, income_statement, cashflow_statement, full_statement}, default: balance_statement
    period -> str{annual, quarter}, default: annual
    limit -> number, default: 10
    as_reported -> boolean{True, False}, default: False
    
    
    Returns
    ============================================
    pandas dataframe

Method get_financial_data allow us to find comprehensive financial info for annual or quarterly period.

tesla_info_df=fmp_api.get_financial_data(symbol='TSLA', report_type='balance_statement', period='annual', limit=10)

Result is a dataframe with 54 positions from Tesla balance sheet statement from 10 annual periods back. With other values for report_type parameter it is possible to extract income sheet statement, cashflow statement or full financial statement of company.

News and sentiment

We are living in world where access to every information from market is possible in one second if you know where to find it. Another problem is to analyze this news and decide how it affect on instrument you are trading on. With Financial Modeling Prep API it is possibile to find news aggregated in one place.

aapl_info_df=fmp_api.get_market_news(symbol='AAPL', market_type='stock', limit=10)

Social media like twitter, sorry I should call it X now, also can shape opinions about company.

aapl_info_df=fmp_api.get_sentiment(symbol='AAPL', limit=10)

As you see we can get dataframe with tweets statistics for Apple hour by hour, and from this point, there is straight way to deeper analysis of sentiment for given company.

Charts

Of course in my considerations about holistioc approach to trading with some asset, stock market companies in this case, I can’t forget about some technical analysis aspects. To have some general view of that how looks current market trend for company, there is possible to present this trend on chart.

tesla_price_df=fmp_api.get_daily_prices(symbol='TSLA')
fmp_api.draw_chart(tesla_price_df)

Chart includes daily prices from period of 5 years. Using draw_chart method you can also specify kind of chart (candlestick, line or ohlc).

Summary

My article contains only description of methods that can help you to be closer to have complete overview of situation in company and overview, how company is perceived in media and social media. To gain some advantages on stock market, there is necessary to analyze data that are collected and use it to make decisions. You can do it by yourself or use some machine learning techniques and models to automatize this process. Whatever you will choose, just remember to take into account risk management.

Trading
Algorithmic Trading
Fundamental Analysis
Financial Data
Financial Data Api
Recommended from ReadMedium