Skip to main content

A python wrapper around the Open FIGI API that leverages pandas DataFrames

Project description

openfigipy

A python wrapper around the Open FIGI v3 API that leverages pandas DataFrames to make requests and return data.

Features Include

  • Automatically throttles requests to respect the API rate limit
  • Automatically handles the chunking and retrieval of mapping jobs
  • Automatically handles the pagination of search requests
  • Queries are given by providing the relevant method with a pandas DataFrame, allowing easy integration with existing reference data pipelines.

Getting Started

To install this library simply run pip install openfigipy.

import pandas as pd
from openfigipy import OpenFigiClient

# api key can either be given with the api_key argument
# or set as the environment variable `OPENFIGI_API_KEY`
ofc = OpenFigiClient()

# establish a requests session
ofc.connect()

# create a dataframe of look-ups - each row represents one query that will
# be batched in jobs
# the column headers represent the relevant key from the open figi api
df = pd.DataFrame({'idType': ['TICKER', 'ID_BB_GLOBAL'],
    'idValue': ['IBM', 'BBG0032FLQC3'], 'currency': ['USD', 'USD'],
    'marketSecDes': ['Equity', 'Equity'], 'exchCode': ['US', None]})

print(df)

#          idType       idValue currency marketSecDes
# 0        TICKER           IBM      USD       Equity
# 1  ID_BB_GLOBAL  BBG0032FLQC3      USD       Equity


result = ofc.map(df)

print(result.head())

#        q_idType     q_idValue q_currency  ... shareClassFIGI securityType2  securityDescription
# 0        TICKER           IBM        USD  ...   BBG001S5S399  Common Stock                  IBM
# 1  ID_BB_GLOBAL  BBG0032FLQC3        USD  ...   BBG001S5N8V8  Common Stock                 AAPL

print(result.columns.tolist())
# ['q_idType',
#  'q_idValue',
#  'q_currency',
#  'q_marketSecDes',
#  'q_exchCode',
#  'query_number',
#  'status_code',
#  'status_message',
#  'figi',
#  'name',
#  'ticker',
#  'exchCode',
#  'compositeFIGI',
#  'securityType',
#  'marketSector',
#  'shareClassFIGI',
#  'securityType2',
#  'securityDescription']

The resulting dataframe will keep your original query columns, prefixed with q_ as well as the documented response from the Open FIGI API. This is to ensure there isn't an overlap i.e. if your query contains exchCode and the results do to. There are also some additional helper columns described below too.

query_number: Shows which query the result is related to, can be helpful when a query returns multiple matches.

result_number: Shows the order in which the results were returned by the Open FIGI API. Generally the best match is shown first (i.e. result_number 0)

status_code: one of ('success', 'warning', 'error') as per the documentation on the Open FIGI API.

status_message: The associated message with the given status_code. Helpful for understanding why results might not have been returned.

Running tests

To run all unit tests for this module:

$ pytest

Please be aware some tests might take some time since they call external APIs.

Todo

  • Setup testing (integration and unit testing). Learn about mocking
  • Setup automatic documentation generation w/ Sphinx
  • explore if type hinting could help
  • Setup automatic linting and checking
  • Setup continuous integration
    • tests
    • documentation
    • pypi publishing

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

openfigipy-0.1.6.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

openfigipy-0.1.6-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file openfigipy-0.1.6.tar.gz.

File metadata

  • Download URL: openfigipy-0.1.6.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.0

File hashes

Hashes for openfigipy-0.1.6.tar.gz
Algorithm Hash digest
SHA256 1975ae98dafa7f00b2fedbb532a3ae7f8bc6ee0211b636fc6770253da92af34b
MD5 28f7ac89066059613777ab737fbcf660
BLAKE2b-256 7124a2444f99ea2a9e1581c4986ae77684a56341c42383f42633c6f5ae777ffe

See more details on using hashes here.

File details

Details for the file openfigipy-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: openfigipy-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.0

File hashes

Hashes for openfigipy-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9c6337b06edba3170c480f424a11c0a5022b1db2a369d8ddde8b74fd0415a23f
MD5 cb0c01c985d7e905ab6ceb546faf9578
BLAKE2b-256 174954e9886caa95a2e7ad043f163a5f86ebf898a3e3e8f525e796979e5c55ef

See more details on using hashes here.

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