* move old example notebooks to v3 folder, update loadHistoricalPriceData and add findSymbols * Create README.md * Update README.md * Update README.md * Update README.md * Vertical diagram instead * important classes * core dependencies * folder structure * devtools * swap order * fix github pages deploy issue * development index * delete expectations for developers * devtools * obbject stuff * add * installation * hub sync * idk if i committed already * add usage page for financial statements * add link to reference page * syntax * numbers * nearly --> more than * easier to read code blocks * codespell * removing mention to provider * add 'orientation' for to_dict * info card for output user preference * put it in a code block * correct user_settings.json example * syntax corrections * fix sentence * get rid of floating point mathc * get rid of other floating point math * add companion example notebook for financial statements, and new section * historical prices usage page * codespell * add commitment of traders section to usage * add a note * codespell * get rid of equals sign * Cleanup docs. with @the-praxs * install * obbject extend * spell * HeadTitle thingies * Update obbject_extensions.md * Update obbject_extensions.md * typo * Update architectural_considerations.md * point to the TET pattern * optional vs required * reviewing the patterns. removed the --pre flag under the assumption this will be the final docs for the release cc @deeleeramone * add a walkthrough * spelling * Add more in the introduction * validator examples * update Copper-to-Gold notebook example for V4 * Update README.md * QA Caveats w @the-praxs * info on class outputs * merge add data sources and add data points * disclaimer on cookiecutter * add missing import to example * slight syntax change * missing code block * missing import * update intrinio example syntax * intrinio syntax update * urls * core and provider merged * example syntax * grammar * Update API banner link * quick-fix-docs cc @minhhoang1023 * Update pip install command for v3 * remove --pre note block * update landing image --------- Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: Luqman <luqazino@gmail.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com> Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
4.7 KiB
Vendored
title, sidebar_position, description, keywords
| title | sidebar_position | description | keywords | |||||
|---|---|---|---|---|---|---|---|---|
| Building Extensions for OpenBB Platform | 4 | This guide provides a comprehensive walkthrough on how to create custom extensions for the OpenBB Platform. It covers the process from generating the extension structure to sharing it with the community. |
|
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
In order to speed up the process of building an extension, we have provided a Cookiecutter template. It serves as a jumpstart for your extension development, so you can focus on the data and not on the boilerplate.
:::info Take into consideration that building an extension requires a good understanding of the OpenBB Platform and that it is limited to a small set of use cases. Before starting, please read the Integrating Data Sources and Points guide to make sure you really need a new extension.
Extension use cases might include:
- Adding a new data provider
- Adding a new toolkit
- Adding a new charting library
- Adding a new asset class :::
Please refer to the Cookiecutter template and follow the instructions there.
This document will walk you through the steps of adding a new extension to the OpenBB Platform.
The high level steps are:
- Generate the extension structure
- Install your dependencies
- Install your new package
- Use your extension (either from Python or the API interface)
- QA your extension
- Share your extension with the community
Best Practices
- Review Platform Dependencies: Before adding any dependency, ensure it aligns with the Platform's existing dependencies.
- Use Loose Versioning: If possible, specify a range to maintain compatibility. E.g.,
>=1.4,<1.5. - Testing: Test your extension with the Platform's core to avoid conflicts. Both unit and integration tests are recommended.
- Document Dependencies: Use
pyproject.tomlandpoetry.lockfor clear, up-to-date records.
Walkthrough
If you do not wish to use the cookiecutter template, this section will walk through the steps of creating a new provider extension.
Generate the extension structure
We first create a new directory for our provider. This should be located under the openbb_platform/providers directory. If I am adding cooldatasource, I would create the following directory structure:
cooldatasource/
├── openbb_cooldatasource/
│ ├── models/
│ │ └── cooldatamodel.py
│ ├── utils/
│ │ └── helper_functions.py
│ └── __init__.py
├── pyproject.toml
└── README.md
In this structure, the cooldatamodel.py and helper_functions.py are the folders handling the logic for obtaining data, as described in the next sections.
The __init__.py defines the provider, using the following code:
from openbb_core.provider.abstract.provider import Provider
cooldatasource_provider = Provider(
name="cooldatasource",
website="",
description="",
credentials=["api_key"],
fetcher_dict={
"MyModel": MyFetcher,
},
)
The pyproject.toml defines the package itself
name = "openbb-cooldatasource"
version = "latest version"
description = "Cool OpenBB Extension"
authors = ["You"]
readme = "README.md"
packages = [{ include = "openbb_cooldatasource" }]
[tool.poetry.dependencies]
python = "^3.9"
openbb-core = "latest openbb core version"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.plugins."openbb_provider_extension"]
cooldatasource = "openbb_cooldatasource:cooldatasource_provider"
Where the last line (poetry.plugins) maps to the provider defined in the __init__.py file.
Install your dependencies and package
The next step is to install the dependencies. We use poetry for dependency management, so from our new directory, we generate the lock file using:
poetry lock
In order to use the extension we will install it using pip. For development mode, we run the following from our directory
pip install -e .
This will install the extension in editable mode, so any changes we make will be reflected in the installed package.
Use your provider extension
Once this is installed, you can use it directly in the openbb package. If you wish to add this to the repo, please follow the instructions in the contributing section, which enforces QA guidelines for adding tests and ensuring the package is implemented properly.