Skip to content

LautaroParada/quickfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuickFS API SDK

forthebadge made-with-python

Python Version Maintenance

Contents

  1. General description
  2. Requirements
  3. Installation
  4. Demo
  5. Documentation
  6. Disclaimer

General description ⬆️

This library is the Python 🐍 unofficial SDK for the QuickFS REST API. It's intended to be used for data extraction for financial valuations.

Requirements ⬆️

  • You need to request an API key with the QuickFS team. Create your account in the following link
  • Python >= 3.8

Installation ⬆️

pip install quickfs

Demo ⬆️

The endpoints of the API will let you request fundamental data for your financial valuation. Here is a demo of its use:

from quickfs import QuickFS
import os

# load the key from the enviroment variables
api_key = os.environ['API_QUICKFS']

client = QuickFS(api_key)

# Request reference data for the supported companies
resp = client.get_api_metadata()
resp = client.get_supported_companies(country='US', exchange='NYSE')

# Usage history
resp = client.get_usage()

# If required, the user can verify the content of the response from the API with the following property:
client.resp
# This property contains the raw form of the request object.

tutorial on how to save and load environment variables in Python -> Hiding Passwords and Secret Keys in Environment Variables (Windows)

Documentation ⬆️

All the methods will use the following instance of the general class:

from quickfs import QuickFS
import os

# load the key from the enviroment variables
api_key = os.environ['API_QUICKFS']
# client instance
client = QuickFS(api_key)

Companies ⬆️

  • get_api_metadata: Returns the available countries and exchanges where to get data.
    • arguments:* None
    • usage:
# get the metadata for the countries and exchanges.
client.get_api_metadata()
  • get_supported_companies: Returns a list of ticker symbols supported by QuickFS. You need to specify a country code (US, CA, MM, AU, NZ, MN, or LN). It is recommendable to use the get_api_metadata to get the references for each argument.
    • arguments:
      • country(str): quickfs code of the country to request data.
      • exchange(str): quickfs code of the exchange to request data.
    • usage:
# get the companies for the NYSE exchange
NYSE = client.get_supported_companies(country='US', exchange='NYSE')
# get the companies for the LSE
LSE = client.get_supported_companies(country='LN', exchange='LONDON')
# get the companies from Australia
ASX = resp = client.get_supported_companies(country='AU', exchange='ASX')
  • get_updated_companies: Returns a list of ticker symbols that were updated with new financial data on or after the specified date (formatted as YYYYMMDD). You need to specify a country code (US, CA, MM, AU, NZ, MN, or LN).
    • arguments:
      • country(str): quickfs code of the country to request data.
      • date(str): specific date to request data, it should be written in the following format YYYYMMDD. Please be aware that may be a delay in the company update and the actual update in the quickfs database.
    • usage
# get the updated companies from New Zeland
client.get_updated_companies(country='NZ', date='20210420')

Metrics ⬆️

  • get_available_metrics: Returns a list of available metrics with the associated metadata.
    • arguments: None
    • usage:
# get the supported metrics by quickfs
client.get_available_metrics()

Datapoints ⬆️

It is highly recommendable to use the country identifier code for non-U.S. stocks. If you do not specify a country, the API will first try to match a U.S.-listed symbol and, if none is found, will then match with a non-U.S. company with the same symbol. The order of the returned data is from oldest to more recent data.

Additionally, the period or period range to query should have the following structure period or from:to respectively. For example, revenue is reported quarterly and annually, as determined by a company's fiscal calendar. FY-9:FY represents the last 10 years of annual revenue figures. Similarly, the last 20 quarters of reported quarterly revenue is characterised by the periods FQ-19:FQ.

  • get_data_range: Returns range of data points for a single company metric.
    • arguments:
      • symbol(str): company symbol. for example: AAPL:US
      • metric(str): QuickFS metric name.
    • usage:
# get the shares outstanding (shares that have been authorized, issued, and purchased by investors and are held by them).
client.get_data_range(symbol='AAPL:US', metric='shares_eop', period='FQ-15:FQ')
  • get_data_full: Pull metadata and all financial statements (annual and quarterly) for all periods for a single stock in one API call.
    • arguments:
      • symbol(str): company symbol. for example: AAPL:US
    • usage:
# get the full data for finnCap Group plc
client.get_data_full(symbol='FCAP:LN')
  • get_data_batch: Batch request for several companies retrieving multiple metrics.
    • arguments:
      • companies(List[str]): List of companies to query.
      • metrics(List[str]): List of metrics to query.
      • period(str): Period or period range to query.
    • usage:
# Get the last 3 years of ROA and ROIC for Cocacola and Pepsi
client.get_data_batch(companies=['KO:US', 'PEP:US'], metrics=['roa', 'roic'], period="FY-2:FY")

Some companies do not have data for a specific metric (This is rare and usually happens for companies with recent IPO's). If this situation happens, you will receive a None as a response from the API. For those cases, I recommend the following code:

# Call all the companies from the NYSE exchange
nyse = client.get_supported_companies(country='US', exchange='NYSE')
# Create a batch request for the selected metrics. The last 4th quarters of data
resp = client.get_data_batch(nyse, 
					metrics=['gross_margin', 'roa', 'enterprise_value'], 
                    period="FQ-3:FQ")
# Assume you have a None response, i.e., some companies will not have data for the requested metric.

# Check the status of the call
print(client.resp) # If it says 207, you have content to use.

print(client.resp._content) # check the error

import json
# filter and extract for the companies that you have data
special_ = json.loads(client.resp._content.decode('utf-8'))['data']
# transform it to a pandas dataframe (if you want it)
import pandas as pd
special_ = pd.DataFrame(special_)

Usage history ⬆️

  • get_usage: Returns your current API usage and limits.
    • arguments: None
    • usage:
client.get_usage()

Disclaimer ⬆️

The information in this document is for informational and educational purposes only. Nothing in this document may be construed as financial, legal or tax advice. The content of this document is solely the opinion of the author, who is not a licensed financial advisor or registered investment advisor. The author is not affiliated as a promoter of QuickFS services.

This document is not an offer to buy or sell financial instruments. Never invest more than you can afford to lose. You should consult a registered professional advisor before making any investment.

About

SDK for the QuickFS API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages