Skip to main content

OpenBB

Project description

Table of contents

Pre-requisites

To install and use the SDK you need:

  • A fresh virtual environment
  • Python 3.8 or higher
  • API keys for the APIs you want to use

For development you need:

  • Poetry 1.5.1 or higher
  • ruff 0.0.256
  • mypy 1.4.1
  • black

Installation

To install the SDK in a virtual environment from the repo root run:

pip install ./openbb_sdk

This will install the SDK and all its dependencies into the site-packages directory of the virtual environment.

API keys

To use your API keys you need to configure them. Here are the 3 options on how to do it:

  1. From local file
  2. At runtime
  3. From OpenBB Hub

1. From local file

You can specify the keys in the ~/.openbb_sdk/user_settings.json file.

Create this file using the following template and replace the values with your keys:

{
  "credentials": {
    "fmp_api_key": "REPLACE_ME",
    "polygon_api_key": "REPLACE_ME",
    "benzinga_api_key": "REPLACE_ME",
    "fred_api_key": "REPLACE_ME"
  }
}

2. From runtime

You can also specify your keys at runtime:

from openbb import obb
obb.user.credentials.fmp_api_key = "REPLACE_ME"
obb.user.credentials.polygon_api_key = "REPLACE_ME"

3. From OpenBB Hub

You can also load your the keys from the OpenBB Hub.

from openbb import obb
openbb.account.login(username="REPLACE_ME", password="REPLACE_ME")

Python Usage

Import and basic usage:

from openbb import obb
aapl = obb.stocks.load("AAPL")
df = aapl.to_dataframe()
df.head()

API Usage

Launch the API with:

uvicorn openbb_core.api.rest_api:app --host 0.0.0.0 --port 8000 --reload

Navigate to http://0.0.0.0:8000/docs to see the swagger API documentation.

Authorize with the developer credentials: openbb/openbb

Docker

You can use the API through Docker.

To build the image, from the repo root run:

docker build -f build/docker/api.dockerfile -t openbb-sdk:latest .

To run this newly-built image:

docker run --rm -p8000:8000 -v ~/.openbb_sdk:/root/.openbb_sdk openbb-sdk:latest

This will mount the local ~/.openbb_sdk directory into the Docker container so you can use the API keys from there and it will expose the API on port 8000.

Development

From the root of the OpenBB Terminal repo, run:

poetry install -C ./openbb_sdk

When developing a specific extension cd into the extension directory and run:

pip install -U -e .

While we're still developing, it is often required to reinstall extensions:

python -c "import openbb; openbb.build()"

You need to do this every time you install or uninstall a new extension or to reinstall all extensions.

Import time

We aim to have a short import time. To measure that we use tuna.

To visualize the import time breakdown by module, run the following commands from openbb_sdk directory:

pip install tuna
python -X importtime openbb/__init__.py 2> import.log
tuna import.log

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

openbb-4.0.0a0.tar.gz (40.7 kB view details)

Uploaded Source

Built Distribution

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

openbb-4.0.0a0-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file openbb-4.0.0a0.tar.gz.

File metadata

  • Download URL: openbb-4.0.0a0.tar.gz
  • Upload date:
  • Size: 40.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.8.17 Windows/10

File hashes

Hashes for openbb-4.0.0a0.tar.gz
Algorithm Hash digest
SHA256 248dd599293d6857596a70aab6a29e1b98c65c5fb129fa563fb082edd82dd50d
MD5 fbc7b4c8b6016670d915b990d3422a8f
BLAKE2b-256 b50de1140a318e9cc6768582efc73442b21fdeb77a07ef8a77a5904965dfef15

See more details on using hashes here.

File details

Details for the file openbb-4.0.0a0-py3-none-any.whl.

File metadata

  • Download URL: openbb-4.0.0a0-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.8.17 Windows/10

File hashes

Hashes for openbb-4.0.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 f922edf795afa4ecce041fcf4c6c5570960e98bdb3ffc1255db39578bf0c65d3
MD5 45a37e746989a6610aa8bc2303c6683b
BLAKE2b-256 43d310dca9f3d156222bf54938481c9da2ea4cdb07f113c84ad8c9cc53adb9ac

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