commitc8c7d836eaMerge:1165e57b40564d08edd8Author: Theodore Aptekarev <aptekarev@gmail.com> Date: Sat Aug 5 15:09:10 2023 +0300 Merge branch 'develop' into feature/openbb-sdk-v4 commit564d08edd8Author: Pratyush Shukla <ps4534@nyu.edu> Date: Fri Aug 4 23:25:47 2023 +0530 add `--india` flag to `stocks/load` (#5281) * add `--india` flag to `stocks/load` Add ticker, set `india` and voila! * updated "help" * added check for `.ns`, `.NS` in ticker * consolidated conditions into 1 line commit1165e57b40Author: montezdesousa <montezdesousa@gmail.com> Date: Fri Aug 4 10:56:20 2023 +0100 make some provider args optional commitafbd4a69aaAuthor: montezdesousa <montezdesousa@gmail.com> Date: Fri Aug 4 10:45:28 2023 +0100 rename some fetcher vars commit8f0b748270Author: montezdesousa <montezdesousa@gmail.com> Date: Fri Aug 4 10:37:43 2023 +0100 move helpers and descriptions to util.py directory commit41e800ad6aAuthor: James Maslek <jmaslek11@gmail.com> Date: Fri Aug 4 05:06:15 2023 -0400 Custom request for all providers (#5280) * breakpoint 1 * breakpoint pt 1 * Finish fred request * Add **kwargs to all fmp funcs * Moved all fmp funcs to custom request * benzinga requests * add polygon requests * remove comment * move make_request to helpers --------- Co-authored-by: montezdesousa <montezdesousa@gmail.com> commitdbc6751843Merge:ce5b93ae4ef1eee44cabAuthor: Henrique Joaquim <h.joaquim@campus.fct.unl.pt> Date: Fri Aug 4 07:37:11 2023 +0100 Merge branch 'develop' into feature/openbb-sdk-v4 commitce5b93ae4eAuthor: James Maslek <jmaslek11@gmail.com> Date: Thu Aug 3 19:59:51 2023 -0400 Custom args to package builder (#5282) commited07f6ad4cAuthor: montezdesousa <montezdesousa@gmail.com> Date: Fri Aug 4 00:46:12 2023 +0100 200 breaks polygon commitf1eee44cabAuthor: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Thu Aug 3 13:58:47 2023 -0700 Feature/options_views: Add a Variety of Views/Charts to Extend the OptionsChains Class (#5222) * add options_chains_view * vsurf charts * skew for strike vs contract * doc string * add chart_volatility * linting * codespell * mypy * types * tmx mypy * update test file * add synthetic long/short to strategies * updates test_options_chains_model.py * updates some docstrings * update documentation * actually commit the documentation page * update documentation screenshots * try catch for 403 error * add tests for options_chains_view * int64 * SPX error handling * add cboe options dashboard for terminal * codespell * enable mouse scroll wheel zoom for charts * declare key values for all widgets * add some more streamlit charts and tables * fix test_yfinance_view.py * conflict resolution * test --------- Co-authored-by: James Maslek <jmaslek11@gmail.com> commitd575c5d52aAuthor: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Thu Aug 3 12:56:44 2023 -0700 Fwd P/E regex fix (#5273) commit373c4f1ea7Author: DidierRLopes <dro.lopes@campus.fct.unl.pt> Date: Thu Aug 3 10:25:47 2023 -0500 Update all_api_keys.json (#5277) * Update all_api_keys.json * Update CONTRIBUTING.md * Create json-yaml-validate * Update release-drafter.yml * Update json-yaml-validate * fix test * add json lint to general * Update tsconfig.json * Add a json_validate exclude to not check tests and certain known violations * fix workflow * not sure why this didnt exclude? --------- Co-authored-by: James Maslek <jmaslek11@gmail.com> commit70f70a81b4Author: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Date: Thu Aug 3 12:43:55 2023 +0100 Hotfix/sdk py38 (#5279) * replace unsupported Annotated, MappingProxyType, is_annotated_dc * fix package builder commit61afffb1f5Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 16:56:40 2023 +0100 typing commit0b3b30ecccAuthor: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 16:51:07 2023 +0100 rename exception for better localization commit49fe650117Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 16:43:54 2023 +0100 update provider readme commit1e0a3c36c4Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 16:43:19 2023 +0100 update provider readme commit9a1b4a8fbaAuthor: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 16:42:02 2023 +0100 update provider readme commit6b93a603dcAuthor: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 16:37:54 2023 +0100 update provider readme commit13d95452c3Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 15:50:20 2023 +0100 to follow the convention commite3d65b502fAuthor: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 14:49:19 2023 +0100 filter commitcc5a334258Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Aug 2 14:42:14 2023 +0100 cleanup filters commitbe864d01f3Author: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Date: Wed Aug 2 14:17:20 2023 +0100 Feature/provider refactoring (#5266) * remove comment * replace registry description * black and add some todos * remove unused var * allow description and move provider to title * fix the data field descriptions * refactor globalnews * added `"limit"` to metadata descriptions * fix cpi command and refactor * refactored `AnalystEstimates` * add concat param * refactored `AvailableIndices` for `economy.available_indices` * sort and set index to date * place it inside exception * move literals to core * rename descriptions dict * add descriptions to cpi data * change description * black * refactored `CompanyOverview` for `stocks.fa.overview` * Updated `DATA_DESCRIPTIONS` in provider metadata * Updated `symbol` description in `DATA_DESCRIPTIONS` * fix stock_news alias * pass standard limit * fix stock news * fix to datframe * rebuild python interface * refactored `CryptoEOD` for `crypto.load` * added Field descriptions * fix polygon stock_news * fix stock_news data * ruff * refactored `DividendCalendar` for `stocks.fa.cal` * refactored `EarningsCalendar` for `stocks.fa.cal` * refactored `EarningsCallTranscript` for `stocks.fa.transcript` * refactored `ExecutiveCompensation` for `stocks.fa.comp` * first round, refactor registry, executor, map * ruff * Allow alias in the provider models for provider specific params * Updated stock news to use alias in query * small fixes * fix interface bug * black * exceptions and typing * ruff * fix docstring * sort providers * push static assets without docstrings * date Field and optional dates params in `CryptoEOD` for fmp and polygon * refactored `ForexEOD` for `forex.load` * add comment * refactored `ForexPairs` and added Polygon provider * removed `_price` models from fmp and polygon * Updated `economy.index` to use `MajorIndicesEOD` * removed `_price` from sdk models * refactored `MajorIndicesEOD` for `economy.index` * refactored `StockEOD` for `stocks.load` * regenerate sdk * ruff * fix bug with global_news * typing * add docstrings to registry map * update docstrings * add executor query arg * follow convention * docstring * inject provider interface instead * doc * safer this way * docs * add abstractmethod decorator * add explicit fetcher property model_name * remove mode_name prop * get model name from query params * force extra params or data to be optional * replace fetcher list by fetcher dict and black * explicit depps in prov interface * explicit depps in prov interface * no formatted creds * no formatted creds * dep injection * dep injection * private methods * just verify credentials * docstring * typing and cut doc * typing * typing * typing * no overkill * ruff * don't block if model not found, just warn * don't block if model not found, just warn * don't block if model not found, just warn * empty list if creds None * check creds before request * just return the data * typing * move query params * ruff * move queryparams * move queryparams * move queryparams * fix a bunch o polygon models * ruff * partial fix fmp models * ruff * refactor more fmps * create dict by alias * refactor more fmp endpoints * bug * add params to transform query * ruff * fix fmp bugs * has to be annotation * rewrite static * typing * append return type to map * support return for generic data type * remove return type for openbb provider * add todo * fix small fred typing error * add more return type info * better message * handle multiple types of data (the fetcher should declare them later) * add comment * ruff * handle returns with generic for now (check juan solution) * fix bug with generic * fix fmp fetchr dict * fill return type in the provider lib for docstrings * polygon stock news * Update economy_router.py (#5254) * remove return type stuff * adapt cpi and overview * rewrite python interface * fix to_dataframe * limit stocks eod output * rename method * mypy * mypy * mypy chart style * mypy provider * mypy ignores * mypy credentials * Added Statements Growth endpoints from FMP * account mypy fix * privatize account method * one more mypy * remove mypy ignore * rename private method * Linting * Docstring generation * Linting * move provider.py into __init__.py * add default to required_credentials -> None * refactored `KeyExecutives` for `stocks.fa.mgmt` * refactored `HistoricalEmployees` for `stocks.fa.emp` * provider docstring * docstring * refactored `HistoricalStockSplits` for `stocks.fa.split` * standardised date in stockeod * refactored ``InstitutionalOwnership` for `stocks.fa.own` * removed unused imports * add `check_fields=False` in `@validator` * historical dividens * remove unused helper * move single used helpers to where they are used * move single used helpers to where they are used * move single used helpers to where they are used * standardise date, vwap in crypto eod and forex eod * rename __commands__ to __extensions__ * change coverage separator * the map cannot change sep * sry * sry again * remove comment * refactored `MajorIndicesConstituents` for `economy.const` * add some descriptions about provider * refactored `PriceTargetConsensus` for `stocks.fa.pt` * refactored `PriceTarget` for `stocks.fa.pta` * refactored `RevenueBusinessLine` for `stocks.fa.revseg` * change metadata file name * docstring * remove unecessary arg * ruff & black * refactored `RevenueGeographic` for `stocks.fa.revgeo` * refactored `RiskPremium` for `economy.risk` * refactored `SECFilings` for `stocks.dd.sec` * refactored `ShareStatistics` for `stocks.fa.shrs` * refactored `StockInsiderTrading` for `stocks.fa.ins` * peers * stock splits * refactored `KeyMetrics` for `stocks.fa.metrics` * refactored `StockMultiples` for `stocks.multiples` * refactor income statement * rebuild * fmp balance * added `StocksOwnership` to `stocks.fa.own` * added `InstitutionalOwnership` to `stocks.fa.ins_own` * refactored `StocksOwnership` for `stocks.fa.own` * cleanup * refactored `TreasuryRates` for `fixedincome.treasury` * reorder balance items * fix polygon bs * refactored `IncomeStatement` for `stocks.fa.balance` * refactored base and types * added static files * cleanup * cleanup * refactored `CashFlowStatement` for `stocks.fa.cash` * added `stocks/fa` static file * black and ruff --------- Co-authored-by: Pratyush Shukla <ps4534@nyu.edu> Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> commit2066d7d4beMerge:fe1073da0907537199afAuthor: Henrique Joaquim <h.joaquim@campus.fct.unl.pt> Date: Wed Aug 2 05:37:20 2023 +0100 Merge branch 'develop' into feature/openbb-sdk-v4 commit07537199afAuthor: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Date: Tue Aug 1 17:27:59 2023 +0100 Move hub api keys ts (#5267) * move hub api keys ts * json instead * update contributing.md * Update all_api_keys.json --------- Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt> commitae91a3f9b9Author: teh_coderer <me@tehcoderer.com> Date: Tue Aug 1 11:05:29 2023 -0500 Hotfix `economy/overview` rates displaying as dates (#5269) * fix: `economy/overview` rates displaying as dates * Fix Test --------- Co-authored-by: James Maslek <jmaslek11@gmail.com> commit3b5fc53cc7Author: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Tue Aug 1 06:41:21 2023 -0700 Adds details/image for installing C++ Build Tools (#5268) * Adds details/image for installing C++ Build Tools * Update installation_updates.md with screenshots * Update installation_updates.md Screenshots for MS C++ Build Tools commitfe1073da09Author: Diogo Sousa <montezdesousa@gmail.com> Date: Tue Aug 1 12:29:42 2023 +0100 only allow setup for allowed system fields commitc8f82e1f8fAuthor: Diogo Sousa <montezdesousa@gmail.com> Date: Tue Aug 1 12:04:16 2023 +0100 reorder system settings attrs commit21c69a510fMerge:379a5518fad212a8e270Author: Theodore Aptekarev <aptekarev@gmail.com> Date: Mon Jul 31 20:17:30 2023 +0300 Merge branch 'develop' into feature/openbb-sdk-v4 commitd212a8e270Author: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Mon Jul 31 09:05:22 2023 -0700 hotfix/gdp-units - better GDP units (#5262) * better GDP units * mypy * remove not needed dict * test_oecd_view.py * test_oecd_model.py commitdc30ab3d36Author: teh_coderer <me@tehcoderer.com> Date: Fri Jul 28 21:13:42 2023 -0500 Hotfix/ locking when deploying streamlit app (#5261) * fix locking when deploying streamlit app * Update streamlit_run.py * Update streamlit_run.py commit379a5518faAuthor: hjoaquim <h.joaquim@campus.fct.unl.pt> Date: Fri Jul 28 10:00:39 2023 +0100 small comment on show() implementation commit849e6134eeMerge:27e172802773348c0872Author: Theodore Aptekarev <aptekarev@gmail.com> Date: Thu Jul 27 19:23:10 2023 +0300 Merge branch 'develop' into feature/openbb-sdk-v4 commit27e1728027Merge:afe4c480a241d1359202Author: Henrique Joaquim <h.joaquim@campus.fct.unl.pt> Date: Thu Jul 27 15:04:19 2023 +0100 Merge branch 'develop' into feature/openbb-sdk-v4 commitafe4c480a2Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Jul 26 14:33:37 2023 +0100 fix comment commit531fa104c8Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Jul 26 14:32:00 2023 +0100 rename method and add description commitcc1a84b4d0Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Jul 26 13:15:55 2023 +0100 change method description commitff31d9ab87Author: Diogo Sousa <montezdesousa@gmail.com> Date: Wed Jul 26 12:52:54 2023 +0100 check sdk token expiration on login
Table of contents
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.
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 .
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.