summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanglewood <85772166+deeleeramone@users.noreply.github.com>2024-06-20 09:20:30 -0700
committerGitHub <noreply@github.com>2024-06-20 16:20:30 +0000
commit826cbcdf9d202ee72a2ef69da034129ed268a723 (patch)
tree777a1f627afca10835188cd4d72a6684c56a21f3
parent186e112993e1a579034efb409f333c029bd98bcb (diff)
Hotfix/fix-chart - Fix data hand off. (#6511)
* fix chart * fix chart * lints and adjustments * black --------- Co-authored-by: Henrique Joaquim <henriquecjoaquim@gmail.com>
-rw-r--r--openbb_platform/obbject_extensions/charting/openbb_charting/charting.py13
-rw-r--r--openbb_platform/obbject_extensions/charting/openbb_charting/charts/helpers.py20
2 files changed, 17 insertions, 16 deletions
diff --git a/openbb_platform/obbject_extensions/charting/openbb_charting/charting.py b/openbb_platform/obbject_extensions/charting/openbb_charting/charting.py
index 662b656142a..efe4672533d 100644
--- a/openbb_platform/obbject_extensions/charting/openbb_charting/charting.py
+++ b/openbb_platform/obbject_extensions/charting/openbb_charting/charting.py
@@ -26,7 +26,10 @@ from openbb_core.provider.abstract.data import Data
from plotly.graph_objs import Figure
from openbb_charting.charts.generic_charts import bar_chart, line_chart
-from openbb_charting.charts.helpers import get_charting_functions
+from openbb_charting.charts.helpers import (
+ get_charting_functions,
+ get_charting_functions_list,
+)
from openbb_charting.core.backend import Backend, create_backend, get_backend
from openbb_charting.core.openbb_figure import OpenBBFigure
from openbb_charting.query_params import ChartParams, IndicatorsParams
@@ -88,7 +91,7 @@ class Charting:
"""Return a list of the available functions."""
functions: List[str] = []
for view in cls._extension_views:
- functions.extend(get_charting_functions(view))
+ functions.extend(get_charting_functions_list(view))
return functions
@@ -96,7 +99,7 @@ class Charting:
"""Return a dict with the available functions."""
functions: Dict[str, Callable] = {}
for view in self._extension_views:
- functions.update(get_charting_functions(view, with_objects=True))
+ functions.update(get_charting_functions(view))
return functions
@@ -339,7 +342,7 @@ class Charting:
charting_function = self._get_chart_function(
self._obbject._route # pylint: disable=protected-access
)
- kwargs["obbject_item"] = self._obbject
+ kwargs["obbject_item"] = self._obbject.results
kwargs["charting_settings"] = self._charting_settings #
kwargs["standard_params"] = (
self._obbject._standard_params # pylint: disable=protected-access
@@ -451,7 +454,7 @@ class Charting:
kwargs["symbol"] = symbol
kwargs["target"] = target
kwargs["index"] = index
- kwargs["obbject_item"] = self._obbject
+ kwargs["obbject_item"] = self._obbject.results
kwargs["charting_settings"] = self._charting_settings
kwargs["standard_params"] = (
self._obbject._standard_params # pylint: disable=protected-access
diff --git a/openbb_platform/obbject_extensions/charting/openbb_charting/charts/helpers.py b/openbb_platform/obbject_extensions/charting/openbb_charting/charts/helpers.py
index e6a818b0109..4d6b97dba07 100644
--- a/openbb_platform/obbject_extensions/charting/openbb_charting/charts/helpers.py
+++ b/openbb_platform/obbject_extensions/charting/openbb_charting/charts/helpers.py
@@ -1,19 +1,15 @@
"""Helper functions for charting."""
from inspect import getmembers, getsource, isfunction
-from typing import Callable, Dict, List, Type, Union
+from typing import Callable, Dict, List, Type
import pandas as pd
from pandas_ta import candles
-def get_charting_functions(
- view: Type, with_objects: bool = False
-) -> Union[List[str], Dict[str, Callable]]:
+def get_charting_functions(view: Type) -> Dict[str, Callable]:
"""Discover charting functions."""
- implemented_functions: Union[List[str], Dict[str, Callable]] = (
- [] if not with_objects else {}
- )
+ implemented_functions: Dict[str, Callable] = {}
for name, obj in getmembers(view, isfunction):
if (
@@ -21,14 +17,16 @@ def get_charting_functions(
and not name.startswith("_")
and "NotImplementedError" not in getsource(obj)
):
- if with_objects:
- implemented_functions[name] = obj
- else:
- implemented_functions.append(name)
+ implemented_functions[name] = obj
return implemented_functions
+def get_charting_functions_list(view: Type) -> List[str]:
+ """Get a list of all the charting functions."""
+ return list(get_charting_functions(view).keys())
+
+
def z_score_standardization(data: pd.Series) -> pd.Series:
"""Z-Score Standardization Method."""
return (data - data.mean()) / data.std()