[Enhancement] openbb-cftc: Improve CFTC Endpoints and Make a Standalone Workspace App For COT Data (#7449)

* improve cftc endpoints and make a standalone workspace app

* mypy

* forgot  couple of files to commit

* test params

* integration test param name

* fix sec-sic-search

* fill some contracts missing category and subcategory, add a workspace workchoices endpoint

* linter

* integration test for cot_choices
This commit is contained in:
Danglewood
2026-04-20 15:36:41 -07:00
committed by GitHub
parent a14208947e
commit 9eca7b9f23
25 changed files with 2917 additions and 385 deletions

View File

@@ -0,0 +1,84 @@
"""Test Regulators extension."""
# pylint: disable=redefined-outer-name
import pytest
from openbb_core.app.model.obbject import OBBject
# pylint: disable=inconsistent-return-statements
@pytest.fixture(scope="session")
def obb(pytestconfig):
"""Fixture to setup obb."""
if pytestconfig.getoption("markexpr") != "not integration":
import openbb # pylint: disable=import-outside-toplevel
return openbb.obb
@pytest.mark.parametrize(
"params",
[
(
{
"query": "grain",
"report_type": "legacy",
"futures_only": False,
"category": None,
"subcategory": None,
"code": None,
"provider": "cftc",
}
),
],
)
@pytest.mark.integration
def test_cftc_cot_search(params, obb):
"""Test the CFTC COT search endpoint."""
result = obb.cftc.cot_search(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"code": "045601",
"report_type": "legacy",
"start_date": None,
"end_date": None,
"limit": 1,
"futures_only": False,
"measure": "all",
"provider": "cftc",
}
),
],
)
@pytest.mark.integration
def test_cftc_cot(params, obb):
"""Test the CFTC COT endpoint."""
result = obb.cftc.cot(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({}),
],
)
@pytest.mark.integration
@pytest.mark.skip(reason="This is not included in the Python interface.")
def test_cftc_get_cot_choices(params, obb):
"""Test the CFTC get_cot_choices endpoint."""
result = obb.cftc.get_cot_choices(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0