* add some charts PR stuff into the main repo * add charting method working for jupyter * dont raise * renamed router * cleaner * ruff * remove print, add todo * minor readme adjustment on url * adding pandas-ta * add pandas-ta to deps * remove optional content * settings env file * Use import relative to the package instead of REPO * using openbb_directory const instead * optional content * optional content * optional content * black * added user styles for console * initializing backend in the charting manager and moving things - working version * pyling * add defaults * ruff * fixing circular import * fix backend creation * cmd location on the args instead * considering charting settings on ta class * cleaning ta extension * adding missing dependency on ta * charts on window * misplaced import * rename file no_import to dummy_backend * redirect import * introducing debug_mode and cleaning todos on ta_class * rename backend folder to core * move charts inside app folder and allocate models * move logs folder into app folder * fixing paths * fixing todos on openbb_figure * setting dummy backend to warn and open in browser if pywry missing * ruff * write msg inside exception * refactor the use of the theme * change package builder module names * removing all references to theme as global variable * ajudsting the usage of kwargs on the charting_router * removing references to rich style and console things * dinamically import the backend functions on the charting manager * add comment * fix backend funcs import * read debug_mode from env * no need to fix manager, but ignore ruff inside __init__ * break command_runner __execute_func into smaller functions * don't raise unless debug mode * replace some errors by OpenBBError * raise provider error if failure * add timedelta minus 7 for eods * 5 is better * print chart error if any * same print for warnings * fixing the broken indicators and removing clutter * warn warnings in debug mode * fix path * fixes on the ta examples * bringing back the utils functions * add error handling messages and sync debug mode * rename base_filter to call_filter * fix chart on api * complete comment * add runtime debug_mode in the static version * removing comment * working with dataframes in the package * ruff * ruff * ruff * readme * ruff --------- Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
3.1 KiB
Vendored
Table of contents
OpenBB SDK
Pre-requisites
To install and use you need:
- A fresh virtual environment
- Python 3.8 or higher
- API keys for the APIs you want to use
To develop you need:
- Poetry 1.5.1 or higher
- ruff 0.0.256
- mypy 1.4.1
- black
Installation
To install the SDK in the virtual environment from the repo root run:
pip install ./openbb_sdk
This will install the SDK and all the dependencies into the site-packages folder of the virtual environment.
While we're still developing it is required to create the static python interface:
import openbb
openbb._rebuild_python_interface()
exit()
Right now you need to do this before the first launch and every time you install or uninstall a new extension.
API keys
To connect to APIs you need to provide the API keys. Here 3 options how you can provide them:
- From local file
- At runtime
- From OpenBB Hub
From local file
You can specify the keys from the ~/.openbb_sdk/user_settings.json file.
Create this file with the following template:
{
"credentials": {
"fmp_api_key": "REPLACE_ME",
"polygon_api_key": "REPLACE_ME",
"benzinga_api_key": "REPLACE_ME",
"fred_api_key": "REPLACE_ME"
}
}
Then add your API keys there and it should work.
From runtime
You can also specify the keys at runtime:
from openbb import obb
obb.settings.credentials.fmp_api_key = "REPLACE_ME"
obb.settings.credentials.polygon_api_key = "REPLACE_ME"
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(symbol="AAPL", start_date="2020-01-01", provider="fmp")
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 the image:
docker run --rm -p8000:8000 -v ~/.openbb_sdk:/root/.openbb_sdk openbb-sdk:latest
This will mount the local ~/.openbb_sdk folder 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 folder and run:
pip install -U -e .