mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
* small changes - moving provider inside the core * uptade readme * lint * remove old provider readme * leftovers * refactor website examples * ruff * fix nox * relock * fix fails_to_deliver headers * fix for tests that have renamed endpoints * fix discovery * removed test for renamed endpoint * fix broken syntax - test_search_financial_attributes * fix cash/income/balance * fix derivatives tests * fix etf tests * fix news tests * fix regulators * black * wrong test param * sort equity gainers/losers by percent * platform markdown generation import * Hotfix/fix int tests core merge (#5779) * removing tests on old endpoint * removing visualization on old endpoint * fixing equity tests * fixing examples * fix news tests * fix index test * example * add comments * example --------- Co-authored-by: Diogo Sousa <montezdesousa@gmail.com> --------- Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Diogo Sousa <montezdesousa@gmail.com> Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com> Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
99 lines
2.6 KiB
Python
99 lines
2.6 KiB
Python
"""Python interface integration tests for the derivatives extension."""
|
|
|
|
import pytest
|
|
from openbb_core.app.model.obbject import OBBject
|
|
|
|
# pylint: disable=too-many-lines,redefined-outer-name
|
|
# pylint: disable=import-outside-toplevel,inconsistent-return-statements
|
|
|
|
|
|
@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": "AAPL"}),
|
|
({"provider": "intrinio", "symbol": "AAPL", "date": "2023-01-25"}),
|
|
({"provider": "cboe", "symbol": "AAPL"}),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_derivatives_options_chains(params, obb):
|
|
result = obb.derivatives.options.chains(**params)
|
|
assert result
|
|
assert isinstance(result, OBBject)
|
|
assert len(result.results) > 0
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
({"symbol": "AAPL"}),
|
|
({"provider": "intrinio", "source": "delayed", "symbol": "AAPL"}),
|
|
({"provider": "intrinio", "symbol": "PLTR", "source": "delayed"}),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_derivatives_options_unusual(params, obb):
|
|
result = obb.derivatives.options.unusual(**params)
|
|
assert result
|
|
assert isinstance(result, OBBject)
|
|
assert len(result.results) > 0
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
(
|
|
{
|
|
"symbol": "ES",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"expiration": "2024-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"provider": "yfinance",
|
|
"interval": "1d",
|
|
"period": "max",
|
|
"prepost": True,
|
|
"adjust": True,
|
|
"back_adjust": True,
|
|
"symbol": "ES",
|
|
"start_date": "2023-05-05",
|
|
"end_date": "2023-06-06",
|
|
"expiration": "2024-06",
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_derivatives_futures_historical(params, obb):
|
|
result = obb.derivatives.futures.historical(**params)
|
|
assert result
|
|
assert isinstance(result, OBBject)
|
|
assert len(result.results) > 0
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
({"symbol": "VX", "date": "2023-01-25", "provider": "cboe"}),
|
|
({"provider": "yfinance", "symbol": "ES", "date": "2023-08-01"}),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_derivatives_futures_curve(params, obb):
|
|
result = obb.derivatives.futures.curve(**params)
|
|
assert result
|
|
assert isinstance(result, OBBject)
|
|
assert len(result.results) > 0
|