diff options
author | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-06-22 20:35:21 -0700 |
---|---|---|
committer | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-06-22 20:35:21 -0700 |
commit | 47b1da921236bf0cb268ffc330d71abde2a856d6 (patch) | |
tree | 6deda449781e79ec7bef6dcd774535e6e0c52f93 | |
parent | bf1dd4f9aa64acc707290c9e53a2d986994bf6a5 (diff) |
charting imports
3 files changed, 25 insertions, 22 deletions
diff --git a/openbb_platform/obbject_extensions/charting/openbb_charting/core/plotly_ta/base.py b/openbb_platform/obbject_extensions/charting/openbb_charting/core/plotly_ta/base.py index 73ac1d31788..c2dba64a4bc 100644 --- a/openbb_platform/obbject_extensions/charting/openbb_charting/core/plotly_ta/base.py +++ b/openbb_platform/obbject_extensions/charting/openbb_charting/core/plotly_ta/base.py @@ -12,11 +12,9 @@ from typing import ( Union, ) -from openbb_charting.core.plotly_ta.data_classes import ChartIndicators, TAIndicator - if TYPE_CHECKING: - from pandas import DataFrame, Series - + from pandas import DataFrame, Series # noqa + from openbb_charting.core.plotly_ta.data_classes import ChartIndicators, TAIndicator # noqa def columns_regex(df_ta: "DataFrame", name: str) -> List[str]: """Return columns that match regex name.""" @@ -104,13 +102,13 @@ class PluginMeta(type): class PltTA(metaclass=PluginMeta): """The base class that all Plotly plugins must inherit from.""" - indicators: ChartIndicators + indicators: "ChartIndicators" intraday: bool = False df_stock: Union["DataFrame", "Series"] df_ta: Optional["DataFrame"] = None df_fib: "DataFrame" close_column: Optional[str] = "close" - params: Optional[Dict[str, TAIndicator]] = {} + params: Optional[Dict[str, "TAIndicator"]] = {} inchart_colors: List[str] = [] show_volume: bool = True diff --git a/openbb_platform/obbject_extensions/charting/openbb_charting/core/to_chart.py b/openbb_platform/obbject_extensions/charting/openbb_charting/core/to_chart.py index affcde5929b..c0618a7025c 100644 --- a/openbb_platform/obbject_extensions/charting/openbb_charting/core/to_chart.py +++ b/openbb_platform/obbject_extensions/charting/openbb_charting/core/to_chart.py @@ -1,23 +1,22 @@ """Module containing the to_chart function.""" -from typing import Any, Dict, Optional, Tuple, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union -import pandas as pd - -from openbb_charting.core.openbb_figure import OpenBBFigure -from openbb_charting.core.plotly_ta.data_classes import ChartIndicators -from openbb_charting.core.plotly_ta.ta_class import PlotlyTA +if TYPE_CHECKING: + from openbb_charting.core.plotly_ta.data_classes import ChartIndicators # noqa + from openbb_charting.core.openbb_figure import OpenBBFigure # noqa + from pandas import DataFrame, Series # noqa def to_chart( - data: Union[pd.DataFrame, pd.Series], - indicators: Optional[Union[ChartIndicators, Dict[str, Dict[str, Any]]]] = None, + data: Union["DataFrame", "Series"], + indicators: Optional[Union["ChartIndicators", Dict[str, Dict[str, Any]]]] = None, symbol: str = "", candles: bool = True, volume: bool = True, prepost: bool = False, volume_ticks_x: int = 7, -) -> Tuple[OpenBBFigure, Dict[str, Any]]: +) -> Tuple["OpenBBFigure", Dict[str, Any]]: """Return the plotly json representation of the chart. This function is used so it can be called at the module level and used out of the box, @@ -26,7 +25,7 @@ def to_chart( Parameters ---------- - data : Union[pd.DataFrame, pd.Series] + data : Union[DataFrame, Series] Data to be plotted. indicators : Optional[Union[ChartIndicators, Dict[str, Dict[str, Any]]]], optional Indicators to be plotted, by default None @@ -46,6 +45,9 @@ def to_chart( Tuple[OpenBBFigure, Dict[str, Any]] Tuple containing the OpenBBFigure and the plotly json representation of the chart. """ + # pylint: disable=import-outside-toplevel + from openbb_charting.core.plotly_ta.ta_class import PlotlyTA + try: ta = PlotlyTA() fig = ta.plot( diff --git a/openbb_platform/providers/nasdaq/openbb_nasdaq/models/top_retail.py b/openbb_platform/providers/nasdaq/openbb_nasdaq/models/top_retail.py index adcc1cc1def..bed0f5a6827 100644 --- a/openbb_platform/providers/nasdaq/openbb_nasdaq/models/top_retail.py +++ b/openbb_platform/providers/nasdaq/openbb_nasdaq/models/top_retail.py @@ -67,12 +67,15 @@ class NasdaqTopRetailFetcher( """Transform the data.""" transformed_data: List[NasdaqTopRetailData] = [] for row in data: - transformed_data.append(NasdaqTopRetailData.model_validate({ - "date": row[0], - "symbol": row[1], - "activity": row[2], - "sentiment": row[3], - }) + transformed_data.append( + NasdaqTopRetailData.model_validate( + { + "date": row[0], + "symbol": row[1], + "activity": row[2], + "sentiment": row[3], + } + ) ) return transformed_data |