Files
OpenBB/openbb_platform
montezdesousa a7c4574919 Feature/basic auth (#5525)
* disable auth by default

* add startup banner

* banner

* create user_auth extension

* add back pymongo for user db

* lint

* add back hub option

* update toml

* remove form

* split auth_hook code

* pydantic v2

* allow db connection

* remove print

* move deps

* remove pymongo from core userservice

* reorg folders

* move props

* fix import

* create inits

* ruff

* rename user service

* rename userservice

* remove unused properties

* rename get_user_service

* ruff

* bad import

* bad import again

* fix userauth service

* now yes

* userdbservice needs to be unique

* move repository code to extension

* move remaining users code to extension

* lint

* pydantic v2

* rename default methods

* rename update to merge

* set merge_dict to private

* user_service: remove singleton

* set user_service as parent class

* fix typing

* add back default settings method used for tests

* + property

* add setter for default user settings

* revert previous: need lunch

* move back some code and start basic auth

* add auth hook

* load ext

* remove userauth ext

* remove from toml

* lint

* set ext name as param

* remove unused env var

* adding admin/pass

* add user/pass and return user_settings

* remove empty file

* improve type hints

* revert some func name changes

* 1 more

* black

* docs

* rename service

* fix tests

* rename env vars

* disable auth by default

* update ext loading

* remove unused pref

* update readme

* update readme + remove default user/pass

* separate user from authentication + lock some rout

* lint

* fix circular import

* fix tests

* readme

* remove comment

* Update README.md

* remove unused repository code

* fix auth env flag

* creds

* update readme

* only disables command auth

* remove link

* pydantic v2

* move app loader

* docstring
2023-10-05 16:25:32 +01:00
..
2023-10-05 16:25:32 +01:00
2023-10-04 15:19:29 +02:00

Downloads LatestRelease

OpenBB is committed to build the future of investment research by focusing on an open source infrastructure accessible to everyone, everywhere.
OpenBBLogo
Check our website at openbb.co

OpenBB Platform Overview

The OpenBB Platform provides a convenient way to access raw financial data from multiple data providers. The package comes with a ready to use REST API - this allows developers from any language to easily create applications on top of OpenBB Platform.

Installation

The command below provides access to the core functionalities behind the OpenBB Platform.

pip install openbb==4.0.0a2

To install extensions that expand the core functionalities specify the extension name or use all to install all.

# Install single extension, e.g. openbb-charting
pip install openbb[charting]==4.0.0a2

# Install all available extensions
pip install openbb[all]==4.0.0a2

Note: These instruction are specific to v4. For installation instructions and documentation for v3 go to our website.

Python

>>> from openbb import obb
>>> output = obb.stocks.load("AAPL")
>>> df = output.to_dataframe()
>>> df.head()
              open    high     low  ...  change_percent             label  change_over_time
date                                ...
2022-09-19  149.31  154.56  149.10  ...         3.46000  September 19, 22          0.034600
2022-09-20  153.40  158.08  153.08  ...         2.28000  September 20, 22          0.022800
2022-09-21  157.34  158.74  153.60  ...        -2.30000  September 21, 22         -0.023000
2022-09-22  152.38  154.47  150.91  ...         0.23625  September 22, 22          0.002363
2022-09-23  151.19  151.47  148.56  ...        -0.50268  September 23, 22         -0.005027

[5 rows x 12 columns]

API keys

To fully leverage the OpenBB Platform you need to get some API keys to connect with data providers. Here are the 3 options on where to set them:

  1. OpenBB Hub
  2. Runtime
  3. Local file

1. OpenBB Hub

Set your keys at OpenBB Hub and get your personal access token from https://my.openbb.co/app/sdk/pat to connect with your account.

>>> from openbb import obb
>>> openbb.account.login(pat="OPENBB_PAT")

2. Runtime

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

>>> # Persist changes in ~/.openbb_platform/user_settings.json
>>> obb.account.save()

3. Local file

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

Populate this file with 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"
  }
}

REST API

The OpenBB Platform comes with a ready to use REST API built with FastAPI. Start the application using this command:

uvicorn openbb_core.api.rest_api:app

Check openbb-core README for additional info.

Install for development

To develop the OpenBB Platform you need to have the following:

  • Git
  • Python 3.8 or higher
  • Virtual Environment with poetry and toml packages installed
    • To install these packages activate your virtual environment and run pip install poetry toml

How to install the platform in editable mode?

  1. Activate your virtual environment
  2. Navigate into the openbb_platform folder
  3. Run python dev_install.py to install the packages in editable mode