mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Hotfix/fix-chart - Fix data hand off. (#6511)
* fix chart * fix chart * lints and adjustments * black --------- Co-authored-by: Henrique Joaquim <henriquecjoaquim@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user