diff --git a/openbb_platform/core/openbb_core/provider/standard_models/euro_short_term_rate.py b/openbb_platform/core/openbb_core/provider/standard_models/euro_short_term_rate.py index dfe1959d37a5..9927f51dea03 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/euro_short_term_rate.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/euro_short_term_rate.py @@ -46,7 +46,7 @@ class EuroShortTermRateData(Data): ) volume: Optional[float] = Field( default=None, - description=DATA_DESCRIPTIONS.get("volume", "")+ " (Millions of €EUR).", + description=DATA_DESCRIPTIONS.get("volume", "") + " (Millions of €EUR).", json_schema_extra={ "x-unit_measurement": "currency", "x-frontend_multiply": 1e6, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/derivatives_views.py b/openbb_platform/extensions/derivatives/openbb_derivatives/derivatives_views.py new file mode 100644 index 000000000000..c83b090e206a --- /dev/null +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/derivatives_views.py @@ -0,0 +1,17 @@ +"""Views for the Derivatives Extension.""" + +from typing import Any, Dict, Tuple + +from openbb_charting.charts.price_historical import price_historical +from openbb_charting.core.openbb_figure import OpenBBFigure + + +class DerivativesViews: + """Derivatives Views.""" + + @staticmethod + def derivatives_futures_historical( # noqa: PLR0912 + **kwargs, + ) -> Tuple[OpenBBFigure, Dict[str, Any]]: + """Get Derivatives Price Historical Chart.""" + return price_historical(**kwargs) diff --git a/openbb_platform/extensions/derivatives/pyproject.toml b/openbb_platform/extensions/derivatives/pyproject.toml index c83acbe4e1ef..3b9d33149c3e 100644 --- a/openbb_platform/extensions/derivatives/pyproject.toml +++ b/openbb_platform/extensions/derivatives/pyproject.toml @@ -17,3 +17,6 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.plugins."openbb_core_extension"] derivatives = "openbb_derivatives.derivatives_router:router" + +[tool.poetry.plugins."openbb_charting_extension"] +derivatives = "openbb_derivatives.derivatives_views:DerivativesViews" diff --git a/openbb_platform/obbject_extensions/charting/integration/test_charting_api.py b/openbb_platform/obbject_extensions/charting/integration/test_charting_api.py index fc9f2b0b646c..76bcba65d7ff 100644 --- a/openbb_platform/obbject_extensions/charting/integration/test_charting_api.py +++ b/openbb_platform/obbject_extensions/charting/integration/test_charting_api.py @@ -758,3 +758,36 @@ def test_charting_fixedincome_government_yield_curve(params, headers): assert chart assert not fig assert list(chart.keys()) == ["content", "format"] + + +@parametrize( + "params", + [ + ( + { + "provider": "yfinance", + "symbol": "ES", + "start_date": "2022-01-01", + "end_date": "2022-02-01", + "chart": True, + } + ) + ], +) +@pytest.mark.integration +def test_charting_derivatives_futures_historical(params, headers): + """Test chart derivatives futures historical.""" + params = {p: v for p, v in params.items() if v} + body = (json.dumps({"extra_params": {"chart_params": {"title": "test chart"}}}),) + query_str = get_querystring(params, []) + url = f"http://0.0.0.0:8000/api/v1/derivatives/futures/historical?{query_str}" + result = requests.get(url, headers=headers, timeout=10, json=body) + assert isinstance(result, requests.Response) + assert result.status_code == 200 + + chart = result.json()["chart"] + fig = chart.pop("fig", {}) + + assert chart + assert not fig + assert list(chart.keys()) == ["content", "format"] diff --git a/openbb_platform/obbject_extensions/charting/integration/test_charting_python.py b/openbb_platform/obbject_extensions/charting/integration/test_charting_python.py index b07b5792de89..34705bb149f0 100644 --- a/openbb_platform/obbject_extensions/charting/integration/test_charting_python.py +++ b/openbb_platform/obbject_extensions/charting/integration/test_charting_python.py @@ -621,3 +621,28 @@ def test_charting_fixedincome_government_yield_curve(params, obb): assert len(result.results) > 0 assert result.chart.content assert isinstance(result.chart.fig, OpenBBFigure) + + +@parametrize( + "params", + [ + ( + { + "provider": "yfinance", + "symbol": "ES", + "start_date": "2022-01-01", + "end_date": "2022-02-01", + "chart": True, + } + ) + ], +) +@pytest.mark.integration +def test_charting_derivatives_futures_historical(params, obb): + """Test chart derivatives futures historical.""" + result = obb.derivatives.futures.historical(**params) + assert result + assert isinstance(result, OBBject) + assert len(result.results) > 0 + assert result.chart.content + assert isinstance(result.chart.fig, OpenBBFigure) diff --git a/openbb_platform/obbject_extensions/charting/openbb_charting/query_params.py b/openbb_platform/obbject_extensions/charting/openbb_charting/query_params.py index 713288742abe..c9caad2ebd9f 100644 --- a/openbb_platform/obbject_extensions/charting/openbb_charting/query_params.py +++ b/openbb_platform/obbject_extensions/charting/openbb_charting/query_params.py @@ -96,7 +96,7 @@ class EtfPricePerformanceChartQueryParams(EquityPricePerformanceChartQueryParams class EtfHoldingsChartQueryParams(ChartQueryParams): - """ "ETF Holdings Chart Query Params.""" + """ETF Holdings Chart Query Params.""" title: Optional[str] = Field( default=None, @@ -399,6 +399,7 @@ class ChartParams: equity_price_historical = EquityPriceHistoricalChartQueryParams economy_fred_series = EconomyFredSeriesChartQueryParams equity_price_historical = EquityPriceHistoricalChartQueryParams + derivatives_futures_historical = EquityPriceHistoricalChartQueryParams equity_price_performance = EquityPricePerformanceChartQueryParams etf_historical = EtfPricePerformanceChartQueryParams etf_holdings = EtfHoldingsChartQueryParams diff --git a/openbb_platform/providers/nasdaq/openbb_nasdaq/__init__.py b/openbb_platform/providers/nasdaq/openbb_nasdaq/__init__.py index 12edf88ae7f6..49cff8dcc29f 100644 --- a/openbb_platform/providers/nasdaq/openbb_nasdaq/__init__.py +++ b/openbb_platform/providers/nasdaq/openbb_nasdaq/__init__.py @@ -7,8 +7,8 @@ from openbb_nasdaq.models.cot import NasdaqCotFetcher from openbb_nasdaq.models.cot_search import NasdaqCotSearchFetcher from openbb_nasdaq.models.economic_calendar import NasdaqEconomicCalendarFetcher -from openbb_nasdaq.models.equity_search import NasdaqEquitySearchFetcher from openbb_nasdaq.models.equity_screener import NasdaqEquityScreenerFetcher +from openbb_nasdaq.models.equity_search import NasdaqEquitySearchFetcher from openbb_nasdaq.models.historical_dividends import NasdaqHistoricalDividendsFetcher from openbb_nasdaq.models.lbma_fixing import NasdaqLbmaFixingFetcher from openbb_nasdaq.models.sp500_multiples import NasdaqSP500MultiplesFetcher