Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/v4-sec-provider: Add SEC provider to V4 #5556

Merged
merged 46 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8a42534
coerce string type, add default=None
deeleeramone Oct 12, 2023
5bdd004
add sec provider and FTD function
deeleeramone Oct 12, 2023
8a098fe
update description
deeleeramone Oct 12, 2023
36af3fe
ruff
deeleeramone Oct 12, 2023
0cd0e1b
data model definitions in standard model already
deeleeramone Oct 12, 2023
0e8783b
Merge branch 'feature/openbb-sdk-v4' of https://github.com/OpenBB-fin…
deeleeramone Oct 12, 2023
8b14e30
duplicate oecd entries in dev_install and pyproject
deeleeramone Oct 12, 2023
74386de
actually commit
deeleeramone Oct 12, 2023
d78650c
integration test
deeleeramone Oct 13, 2023
c7b76f6
merge branch feature/openbb-sdk-v4
deeleeramone Oct 14, 2023
ac74070
add stock search to SEC
deeleeramone Oct 14, 2023
863f920
add company filings for SEC provider
deeleeramone Oct 15, 2023
9fe1f32
integration tests
deeleeramone Oct 15, 2023
5891b4c
merge branch feature/openbb-sdk-v4
deeleeramone Oct 16, 2023
bdc697a
remove duplicated line
deeleeramone Oct 16, 2023
84a1ce1
merge branch feature/openbb-sdk-v4
deeleeramone Oct 20, 2023
05ab6cb
ruff
deeleeramone Oct 20, 2023
819e4e1
**kwargs in Transform Data
deeleeramone Oct 20, 2023
01ce991
some helper functions for later
deeleeramone Oct 20, 2023
b017320
black
deeleeramone Oct 20, 2023
d18081c
add helper for mutual fund and etf lookup
deeleeramone Oct 20, 2023
25ea358
Merge branch 'feature/openbb-sdk-v4' of https://github.com/OpenBB-fin…
deeleeramone Oct 21, 2023
9ec7f0e
add some SEC lookup helpers to a new regulators extension
deeleeramone Oct 22, 2023
fcba9b0
Merge branch 'feature/openbb-sdk-v4' of https://github.com/OpenBB-fin…
deeleeramone Oct 22, 2023
2bb5d10
black
deeleeramone Oct 22, 2023
3013a6b
ruff
deeleeramone Oct 22, 2023
0eae88a
fix test param
deeleeramone Oct 22, 2023
c81dbdc
take institution filter out of sec stock_search
deeleeramone Oct 22, 2023
dd1c8c7
ruff
deeleeramone Oct 23, 2023
010fed0
remove URL that codespell doesn't like
deeleeramone Oct 23, 2023
bfbf30c
add cik-to-ticker map
deeleeramone Oct 23, 2023
b6ad69b
add litigations rss feed
deeleeramone Oct 23, 2023
b7d591b
make openbb-regulators a dependency of openbb-sec
deeleeramone Oct 23, 2023
07df91f
Merge branch 'feature/openbb-sdk-v4' of https://github.com/OpenBB-fin…
deeleeramone Oct 23, 2023
0917010
add SIC search
deeleeramone Oct 24, 2023
4070bab
Merge branch 'feature/openbb-sdk-v4' of https://github.com/OpenBB-fin…
deeleeramone Oct 25, 2023
6ae7d10
improve ftd and remove BeautifulSoup from SEC dependencies
deeleeramone Oct 25, 2023
73cdc8d
fix parsing the zip files pre-2009
deeleeramone Oct 25, 2023
c1498c5
ruff
deeleeramone Oct 25, 2023
6386038
Merge branch 'feature/openbb-sdk-v4' of https://github.com/OpenBB-fin…
deeleeramone Oct 26, 2023
59c22d3
update descriptions
deeleeramone Oct 26, 2023
1bb0a92
recapture ftd test
deeleeramone Oct 26, 2023
52f7396
merge branch feature/openbb-sdk-v4
deeleeramone Oct 29, 2023
0fb93ec
tests params
deeleeramone Oct 29, 2023
3f82b84
typo
deeleeramone Oct 29, 2023
1054b0f
change limit param to 1 in test_sec_stock_ftd
deeleeramone Oct 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openbb_platform/dev_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
openbb-biztoc = { path = "./providers/biztoc", optional = true, develop = true }
openbb-cboe = { path = "./providers/cboe", optional = true, develop = true }
openbb-quandl = { path = "./providers/quandl", optional = true, develop = true }
openbb-sec = { path = "./providers/sec", optional = true, develop = true }
openbb-yfinance = { path = "./providers/yfinance", optional = true, develop = true }

openbb-charting = { path = "./extensions/charting", optional = true, develop = true }
Expand Down
15 changes: 15 additions & 0 deletions openbb_platform/extensions/regulators/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# OpenBB Regulators Extension

This extension provides a structure for data sourced from various global market regulators.

## Installation

To install the extension, run the following command in this folder:

```bash
pip install openbb-regulators
```

For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_platform/CONTRIBUTING.md).

Documentation available [here](https://docs.openbb.co/sdk).
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import base64

import pytest
import requests
from openbb_core.env import Env
from openbb_provider.utils.helpers import get_querystring


@pytest.fixture(scope="session")
def headers():
userpass = f"{Env().API_USERNAME}:{Env().API_PASSWORD}"
userpass_bytes = userpass.encode("ascii")
base64_bytes = base64.b64encode(userpass_bytes)

return {"Authorization": f"Basic {base64_bytes.decode('ascii')}"}


@pytest.mark.parametrize(
"params",
[
({"symbol": "TSLA"}),
({"symbol": "SQQQ"}),
],
)
@pytest.mark.integration
def test_regulators_sec_cik_map(params, headers):
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/regulators/sec/cik_map?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@pytest.mark.parametrize(
"params",
[
({"query": "berkshire hathaway"}),
],
)
@pytest.mark.integration
def test_regulators_sec_institutions_search(params, headers):
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/regulators/sec/institutions_search?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@pytest.mark.parametrize(
"params",
[
({"symbol": "AAPL", "limit": 3, "type": "8-K"}),
({"cik": "0001067983", "limit": 3, "type": "10-Q"}),
],
)
@pytest.mark.integration
def test_regulators_sec_filings(params, headers):
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/regulators/sec/filings?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@pytest.mark.parametrize(
"params",
[({"query": "2022"}), ({"url": "https://xbrl.fasb.org/us-gaap/2014/entire/"})],
)
@pytest.mark.integration
def test_regulators_sec_schema_files(params, headers):
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/regulators/sec/schema_files?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@pytest.mark.parametrize(
"params",
[
({"query": "0000909832"}),
({"query": "0001067983"}),
],
)
@pytest.mark.integration
def test_regulators_sec_symbol_maps(params, headers):
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/regulators/sec/symbol_map?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@pytest.mark.parametrize(
"params",
[({})],
)
@pytest.mark.integration
def test_regulators_sec_rss_litigation(params, headers):
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/regulators/sec/rss_litigation?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@pytest.mark.parametrize(
"params",
[({"query": "oil", "use_cache": False})],
)
@pytest.mark.integration
def test_regulators_sec_sic_search(params, headers):
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/regulators/sec/sic_search?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""Test Regulators extension."""
import pytest
from openbb_core.app.model.obbject import OBBject


@pytest.fixture(scope="session")
def obb(pytestconfig):
"""Fixture to setup obb."""

if pytestconfig.getoption("markexpr") != "not integration":
import openbb

return openbb.obb


@pytest.mark.parametrize(
"params",
[
({"symbol": "TSLA"}),
({"symbol": "SQQQ"}),
],
)
@pytest.mark.integration
def test_regulators_sec_cik_map(params, obb):
result = obb.regulators.sec.cik_map(**params)
assert result
assert isinstance(result, OBBject)
assert hasattr(result.results, "cik")
assert isinstance(result.results.cik, str)


@pytest.mark.parametrize(
"params",
[
({"symbol": "AAPL", "limit": 3, "type": "8-K"}),
({"cik": "0001067983", "limit": 3, "type": "10-Q"}),
],
)
@pytest.mark.integration
def test_regulators_sec_filings(params, obb):
result = obb.regulators.sec.filings(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0


@pytest.mark.parametrize(
"params",
[({"query": "2022"}), ({"url": "https://xbrl.fasb.org/us-gaap/2014/entire/"})],
)
@pytest.mark.integration
def test_regulators_sec_schema_files(params, obb):
result = obb.regulators.sec.schema_files(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results.files) > 0


@pytest.mark.parametrize(
"params",
[
({"query": "0000909832"}),
({"query": "0001067983"}),
],
)
@pytest.mark.integration
def test_regulators_sec_symbol_map(params, obb):
result = obb.regulators.sec.symbol_map(**params)
assert result
assert isinstance(result, OBBject)
assert hasattr(result.results, "symbol")
assert isinstance(result.results.symbol, str)


@pytest.mark.parametrize(
"params",
[({})],
)
@pytest.mark.integration
def test_regulators_sec_rss_litigation(params, obb):
result = obb.regulators.sec.rss_litigation(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0


@pytest.mark.parametrize(
"params",
[({"query": "oil", "use_cache": False})],
)
@pytest.mark.integration
def test_regulators_sec_sic_search(params, obb):
result = obb.regulators.sec.sic_search(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# pylint: disable=W0613:unused-argument
# ruff: noqa: F401
"""Companies House Router."""

from openbb_core.app.model.command_context import CommandContext
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.provider_interface import (
ExtraParams,
ProviderChoices,
StandardParams,
)
from openbb_core.app.query import Query
from openbb_core.app.router import Router
from pydantic import BaseModel

router = Router(prefix="/companies_house")

# @router.command(model="Filings")
# def filings(
# cc: CommandContext,
# provider_choices: ProviderChoices,
# standard_params: StandardParams,
# extra_params: ExtraParams,
# ) -> OBBject[BaseModel]:
# """Look up Companies House filings by ID number."""
# return OBBject(results=Query(**locals()).execute())
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# pylint: disable=import-outside-toplevel, W0613:unused-argument
# ruff: noqa: F401
"""Regulators Router."""


from openbb_core.app.model.command_context import CommandContext
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.provider_interface import (
ExtraParams,
ProviderChoices,
StandardParams,
)
from openbb_core.app.query import Query
from openbb_core.app.router import Router
from pydantic import BaseModel

from openbb_regulators.companies_house.companies_house_router import (
router as companies_house_router,
)
from openbb_regulators.sec.sec_router import router as sec_router

router = Router(prefix="")
router.include_router(sec_router)
router.include_router(companies_house_router)


# @router.command(model="")
# def load(
# cc: CommandContext,
# provider_choices: ProviderChoices,
# standard_params: StandardParams,
# extra_params: ExtraParams,
# ) -> OBBject[BaseModel]:
# """Stock Historical price. Load stock data for a specific ticker."""
# return OBBject(results=Query(**locals()).execute())
Empty file.
Loading
Loading