Files
OpenBB/openbb_platform/extensions/derivatives/integration/test_derivatives_python.py
Danglewood e2f7e597fa feature/cboe-async: Refactor Cboe for Async (#5900)
* refactor cboe for async

* codespell

* unused imports

* pylint

* more pylint

* platform metadata

* classmethod decorator

* test params

* intrinio quote

* test param names

* date in test needs to be a datetime.date not string

* make fmp unix timestamp tz-aware and normalize percent change

* different way of parsing datetime string

* recapture cboe equity historical test

* unused import

* index snapshot update

* black

* extension map

* pylint

* cboe pyproject.toml

* proposal to standardize equity_quote

* one more file

* removing changes on static assets

* index_historical

* index_historical again

* last_time -> last_timestamp

* obsolete router path

* fix tests

* test param

* restore market index deprecation that I forgot about

* fixing tests

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
2024-01-22 15:17:42 +00:00

87 lines
2.3 KiB
Python

"""Python interface integration tests for the derivatives extension."""
import pytest
from extensions.tests.conftest import parametrize
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
@parametrize(
"params",
[
({"provider": "intrinio", "symbol": "AAPL", "date": "2023-01-25"}),
({"provider": "cboe", "symbol": "AAPL", "use_cache": False}),
],
)
@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
@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
@parametrize(
"params",
[
(
{
"provider": "yfinance",
"interval": "1d",
"symbol": "CL,BZ",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"expiration": "2025-12",
}
),
],
)
@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
@parametrize(
"params",
[
({"symbol": "VX", "provider": "cboe", "date": None}),
({"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