Skip to main content

A python-based wrapper for the Financial Models Prep pro API (fmpcloud.io) for financial data of public companies

Project description

A Python wrapper library for the Financial Model Prep pro (fmpcloud.io)

PyPI Latest Release Package Status License downloads

pyfmpcloud is a Python wrapper library for the Financial Model Prep pro API (fmpcloud.io)

Installation

Use the package manager pip to install pyfmpcloud

pip install pyfmpcloud --upgrade --no-cache-dir 

Alternatively, download and extract the *.tar.gz folder, and run the following command from the root directory in your shell:

make setup

Usage

pyfmpcloud contains a settings module and four other modules that are the core of the pyfmpcloud API wrapper.

The following sections show the four main modules for pyfmpcloud and their usage with examples. Note that the modules are structured in the same way as the API documentation that can be found at fmpcloud.io API documentation. The names of the functions within the modules also follow the naming convention on this documentation. This helps with staying consistent. The four modules and their functions are as follows:

Settings

from pyfmpcloud import settings

General helper functions to access and update settings for the library environment. These are:

set_apikey: Please set your API Key in this file using the settings.set_apikey([YOUR KEY]). The key can be retrieved from fmpcloud.io by signing up. Default is the 'demo' key. Example:

settings.set_apikey('stringcontainingyourapikey')

get_apikey: Gets the currently set API key. Default is demo

settings.get_apikey()

get_urlroot: Gets the root API url for fmpcloud.io

settings.get_urlroot()

get_urlrootfmp: Gets the root API url for fmpcloud's sister API financialmodelprep.com. Good to have but is not currently used in the wrapper.

settings.get_urlrootfmp()

Company Valuation

from pyfmpcloud import company_valuation as cv

Here, you have functions that wrap around the APIs listed in fmpcloud.io (see fmpcloud.io API documentation) under Company Valuation. These are:

rss_feed: This function returns updates for all filings of public companies, including their filing type (10-Q, 13-F, etc.), their CIK number, and the date and time of the filing.

cv.rss_feed()

balance_sheet: This function returns the balance sheet information of the specified ticker. Inputs are: ticker, period('annual' or 'quarter') and ftype('full', 'growth', 'short' or 'growth-short')

Examples:

cv.balance_sheet(ticker = 'AAPL', period = 'annual', ftype = 'full')
cv.balance_sheet(ticker = 'AAPL', period = 'annual', ftype = 'growth')
cv.balance_sheet(ticker = 'AAPL', period = 'annual', ftype = 'short')
cv.balance_sheet(ticker = 'AAPL', period = 'annual', ftype = 'growth-short')
cv.balance_sheet(ticker = 'AAPL', period = 'quarter', ftype = 'full')

income_statement: This function returns the income statement of the specified ticker. Inputs arguments are: ticker, period('annual' or 'quarter') and ftype('full', 'growth')

Examples:

cv.balance_sheet(ticker = 'AAPL', period = 'annual', ftype = 'full')
cv.balance_sheet(ticker = 'AAPL', period = 'annual', ftype = 'growth')
cv.balance_sheet(ticker = 'AAPL', period = 'quarter', ftype = 'full')
cv.balance_sheet(ticker = 'AAPL', period = 'quarter', ftype = 'growth')

cash_flow_statement: This function returns the cash-flow statement of the specified ticker. Inputs are Inputs are: ticker, period('annual' or 'quarter') and ftype('full' or 'growth')

Examples:

cv.cash_flow_statement(ticker = 'AAPL', period = 'annual', ftype = 'full')
cv.cash_flow_statement(ticker = 'AAPL', period = 'annual', ftype = 'growth')
cv.cash_flow_statement(ticker = 'AAPL', period = 'quarter', ftype = 'full')
cv.cash_flow_statement(ticker = 'AAPL', period = 'quarter', ftype = 'growth')

financial_ratios: This function returns the financial ratios of the specified ticker. ttm can provide these ratios for the trailing twelve months. Inputs arguments are: ticker, period('annual' or 'quarter') and ttm(True or False)

Examples:

cv.financial_ratios(ticker = 'AAPL', period = 'annual', ttm = True)
cv.financial_ratios(ticker = 'AAPL', period = 'annual', ttm = False)
cv.financial_ratios(ticker = 'AAPL', period = 'quarter', ttm = True)
cv.financial_ratios(ticker = 'AAPL', period = 'quarter', ttm = False)

key_metrics : This function returns the key metrics of the specified ticker. Inputs are: ticker and period('annual' or 'quarter')

Examples:

cv.key_metrics(ticker = 'AAPL', period = 'annual')
cv.key_metrics(ticker = 'AAPL', period = 'quarter')

enterprise_value : This function returns the enterprise value of the specified ticker. Inputs are: ticker and period('annual' or 'quarter')

Examples:

cv.enterprise_value(ticker = 'AAPL', period = 'annual')
cv.enterprise_value(ticker = 'AAPL', period = 'quarter')

financial_statements_growth : This function returns the financial statements growth/evolution over time of the specified ticker. Inputs are: ticker and period('annual' or 'quarter')

Examples:

cv.financial_statements_growth(ticker = 'AAPL', period = 'annual')
cv.financial_statements_growth(ticker = 'AAPL', period = 'quarter')

dcf : This function returns the discounted cashflow value of the specified ticker, over time. Inputs are: ticker and history('today', 'daily', 'annual' or 'quarter')

Examples:

cv.dcf(ticker = 'AAPL', history = 'today')
cv.dcf(ticker = 'AAPL', history = 'daily')
cv.dcf(ticker = 'AAPL', history = 'annual')
cv.dcf(ticker = 'AAPL', history = 'quarter')

market_capitalization : This function returns the market capitalization of the specified ticker, over time. Inputs are: ticker and history('today', 'daily')

Examples:

cv.market_capitalization(ticker = 'AAPL', history = 'today')
cv.market_capitalization(ticker = 'AAPL', history = 'daily')

rating: This function returns the ratings of the specified ticker, over time. Inputs are: ticker and history('today', 'daily')

Examples:

cv.rating(ticker = 'AAPL', history = 'today')
cv.rating(ticker = 'AAPL', history = 'daily')

stock_screener : A function to screen stocks based on market capitalization, beta, dividend payouts, trading volume and sector. Also allows you to limit the number of rows returned from the request. The following are the arguments to apply the filter.

mcgt : float input for market cap greater than. mclt : float input for market cap less than bgt : float input for beta greater than blt : float input for beta less than divgt : float input for dividend greater than divlt : float input for dividend less than volgt : float input for volume greater than vollt : float input for volume less than sector : string input for sector. limit : int input for limit of returned rows from the API request

Examples:

cv.stock_screener('AAPL', mcgt = 1000000, mclt = 5000000, bgt = 1.2, blt = 2.1)
cv.stock_screener('AAPL', mcgt = 1000000, mclt = 5000000, volgt = 500000, blt = 2.1, divgt = 1)

Stock Time Series

from pyfmpcloud import stock_time_series as sts

These contain functions from fmpcloud.io 's API for Stock Time Series (see fmpcloud.io API documentation) under Stock Time Series. these are:

real_time_quote: Real-Time Quotes for specified tickers. Input is ticker

Example:

sts.real_time_quote('AAPL')

ticker_search: Partial matching of tickers based on provided string element. Inputs are match, limit and exchange

Examples:

sts.ticker_search(match = 'AA', limit = 100, exchange = 'Nasdaq')

historical_stock_data: Historical stock data for specified tickers based on specified period ('1 min', '5min', '15min', '30min' and '1hour', or daily change type dailytype ('line', 'change'). period and dailytype cannot be used together. If dailytype is used, you can specify start and end dates for your request. Dates are a simple string (not a datetime object) in the format yyyy-mm-dd. Alternatively, you can also specify a request for daily prices over the last number of days using last

Examples:

sts.historical_stock_data('AAPL', period = '1hour')
sts.historical_stock_data('AAPL', dailytype = 'line', start = '2019-04-15', end = '2020-04-15')
sts.historical_stock_data('AAPL', dailytype = 'change', start = '2019-04-15', end = '2020-04-15')
sts.historical_stock_data('AAPL', dailytype = 'change', last = 30)

batch_request_eod_prices: batch request for EOD prices for a single date (if no date is specified, it will return the EOD prices for the last market close). Only accepts an array of strings, even for a single ticker request. If tickers are provided, a date must be provided. If no ticker is provided, it will return the EOD prices for all tickers. date is a simple string (not a datetime object) in the format yyyy-mm-dd

Examples:

sts.batch_request_eod_prices()
sts.batch_request_eod_prices(['AAPL'], date='2020-04-15')
sts.batch_request_eod_prices(date='2020-04-15')
sts.batch_request_eod_prices(['AAPL', 'FB', 'MSFT'], date='2020-04-15')

stocks_list: List of all available tickers.

Example:

sts.stock_list()

company_profile: Company profile for the specified ticker

Example:

sts.company_profile('AAPL')

available_markets_and_tickers: List of available stocks on the specified market (e.g. Nasdaq), and prices of the tickers on the specified market. Inputs are markettype ('ETF','Commodities','Euronext','NYSE','AMEX','TSX','Mutual Funds','Index' or 'Nasdaq') and a boolean marketprices` (True or False) to indicate if prices of the tickers for the specified markettypes are sought.

Examples:

sts.available_markets_and_tickers(markettype = 'Nasdaq')
sts.available_markets_and_tickers(markettype = 'Nasdaq', marketprices = True)

stock_market_performances: Overview of the market performance across specified performance type, such as by sector, or by largest gainers. Input is performancetype('active','gainers','losers','sector','sector historical', 'market hours')

Examples:

sts.stock_market_performances(performancetype = 'active')
sts.stock_market_performances(performancetype = 'market hours')

Forex

from pyfmpcloud import forex as fx

These contain functions from fmpcloud.io 's API for Forex (see fmpcloud.io API documentation). these are:

forex_realtime_quote: Real-time quotes for specified fx tickers. You can request the list of forex, their prices, or both through the fxtype ('list', 'price', 'both') argument.

Examples:

fx.forex_realtime_quote(fxtype = 'list')
fx.forex_realtime_quote(fxtype = 'price')
fx.forex_realtime_quote(fxtype = 'both')

forex_historical_data: Historical fx data for specified tickers based on specified period ('1 min', '5min', '15min', '30min' and '1hour', or daily change type dailytype ('line', 'change'). period and dailytype cannot be used together. If dailytype is used, you can specify start and end dates for your request. Dates are a simple string (not a datetime object) in the format yyyy-mm-dd. Alternatively, you can also specify a request for daily fx prices over the last number of days using last

Examples:

fx.forex_historical_data('EURUSD', period = '1hour')
fx.forex_historical_data('EURUSD', dailytype = 'line', start = '2019-04-15', end = '2020-04-15')
fx.forex_historical_data('EURUSD', dailytype = 'change', start = '2019-04-15', end = '2020-04-15')
fx.forex_historical_data('EURUSD', dailytype = 'change', last = 30)

Crypto

from pyfmpcloud import crypto as cp

These contain functions from fmpcloud.io 's API for Crypto (see fmpcloud.io API documentation). these are:

crypto_realtime_quote: Real-time quotes for specified crypto tickers. You can request the list of crypto or their prices through the cryptotype ('list', 'price') argument.

Examples:

cp.crypto_realtime_quote(fxtype = 'list')
cp.crypto_realtime_quote(fxtype = 'price')

crypto_historical_data: Historical crypto data for specified tickers based on specified period ('1 min', '5min', '15min', '30min' and '1hour', or daily change type dailytype ('line', 'change'). period and dailytype cannot be used together. If dailytype is used, you can specify start and end dates for your request. Dates are a simple string (not a datetime object) in the format yyyy-mm-dd. Alternatively, you can also specify a request for daily fx prices over the last number of days using last

Examples:

cp.crypto_historical_data('BTCUSD', period = '1hour')
cp.crypto_historical_data('BTCUSD', dailytype = 'line', start = '2019-04-15', end = '2020-04-15')
cp.crypto_historical_data('BTCUSD', dailytype = 'change', start = '2019-04-15', end = '2020-04-15')
cp.crypto_historical_data('BTCUSD', dailytype = 'change', last = 30)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

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

pyfmpcloud-0.3.3.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfmpcloud-0.3.3-py3.7.egg (27.3 kB view details)

Uploaded Egg

File details

Details for the file pyfmpcloud-0.3.3.tar.gz.

File metadata

  • Download URL: pyfmpcloud-0.3.3.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pyfmpcloud-0.3.3.tar.gz
Algorithm Hash digest
SHA256 9c76a33d819788f9896cd3cf83e47874137f8af512ab0cf8455564a9543124de
MD5 4d2cf77d113c72b064e9e8ff4ac09884
BLAKE2b-256 df12670d4428356a2a915c56d02689929a291c6de66e397cfda43544dc4005ce

See more details on using hashes here.

File details

Details for the file pyfmpcloud-0.3.3-py3.7.egg.

File metadata

  • Download URL: pyfmpcloud-0.3.3-py3.7.egg
  • Upload date:
  • Size: 27.3 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pyfmpcloud-0.3.3-py3.7.egg
Algorithm Hash digest
SHA256 289738b46e0915a335ed78c90d746df33852bbd4f54b51fa6886801bf8a141bf
MD5 0a07b2175617fc77efdca899b7655273
BLAKE2b-256 b749989acdf76865db53689dae6cc414e5211f90da8166c8b6f2147bf01d67ea

See more details on using hashes here.

Supported by

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