Files
OpenBB/openbb_providers
Diogo Sousa 4b54670913 pin urllib
2023-07-03 13:11:57 +01:00
..
2023-07-03 11:34:14 +02:00
2023-07-03 13:11:57 +01:00
2023-06-30 20:19:25 +02:00

THIS README IS A WORK IN PROGRESS AND CAN BE VERY MUCH OUT OF DATE. REFRESH THE PAGE UNTIL THIS BANNER IS GONE

Table of contents

Temporary glossary

  • Provider : A Provider is a Financial Data Provider such as FMP, Polygon, Benzinga, etc.
  • QueryParams : A set of parameters that define a request to a Provider. It is defined by the user.
  • Provider QueryParams : A set of parameters which are defined by the Provider.
  • Data : A standardized set of data that is returned by a Provider and then standardized.
  • Provider Data : Provider Data is a raw set of data that is returned by a Provider as is.

openbb-provider

This library aim to give a coherent access to Financial Data Providers.

It provides coherence on:

  • QueryParams : one can define QueryParams and use them on multiple Financial Data Providers.
  • Data : one can process the data provided by multiple Financial Data Providers as if there were from the same one.

Functional Requirements

Functional requirements are the following:

  • Provide a standardized access to similar Data from multiple Data Providers.
  • Use the same QueryParams to query similar Data from multiple Providers.
  • Get similar Data from multiple Provider and process it as if there were from the same Provider.

How to use it?

Prerequisites

  • Python 3.9 or higher
  • .env file with the following variables:
    • FMP_API_KEY
    • POLYGON_API_KEY
    • BENZINGA_API_KEY
  • Install the dependencies:
    • pip install poetry==1.4.1
    • poetry install

1. Defining : OpenBB QueryParams

from openbb_provider.model.data.stock_eod import StockEODQueryParams

query = StockEODQueryParams(
  symbol="AAPL",
  start_date="2022-01-01",
)

2. Querying the Provider Table : OpenBB QueryParams -> OpenBB Data

from openbb_provider.provider.provider_registry import provider_registry

data = provider_registry.fetch(provider_name="fmp", query=query)
print(data)

Different ways of usage

1. OpenBB QueryParams -> OpenBB Data

This is the most common way of usage that the SDK v4 users will use.

provider_registry.fetch(provider_name="fmp", query=query)

2. OpenBB QueryParams -> Provider Data

This way uses the standardized query to obtain the raw data from the Provider. This is useful when the user wants specific data that is not available in the standardized data.

provider_registry.fetch_provider_data(provider_name="fmp", query=query)

3. Provider QueryParams -> OpenBB Data

This way uses the Provider QueryParams to obtain the standardized data. This is useful when the user wants to use a specific query field that is not available in the standardized query.

provider_registry.standardized(provider_name="fmp", query=provider_query)

4. Provider QueryParams -> Provider Data

This way uses the Provider QueryParams to obtain the raw data from the Provider. This is useful when the user wants specific data that is not available in the standardized data and wants to use a specific query field that is not available in the standardized query. It is the same a using the Provider directly.

This will primarily be used for integration tests so that we can notice Provider API changes in time and adjust the mapping accordingly.

provider_registry.simple(provider_name="fmp", query=provider_query)

Data Mapping

The data mapping is done in the following file.

Package extension : Adding a new Provider extension

1. Build a Python package

poetry new opebb-provider-your_extension

2. Entrypoint

Add an entrypoint for the extension inside your pyproject.toml file

# File pyproject.toml
...
[tool.poetry.extensions."openbb_provider_extension"]
extension_name_space = "my_extension.provider:provider_module"

3. Install the extension

poetry install