openbb-charting 2.1.2__tar.gz → 2.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/PKG-INFO +35 -6
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/README.md +34 -5
- openbb_charting-2.1.3/openbb_charting/__init__.py +14 -0
- openbb_charting-2.1.2/openbb_charting/__init__.py → openbb_charting-2.1.3/openbb_charting/charting.py +55 -59
- {openbb_charting-2.1.2/openbb_charting/utils → openbb_charting-2.1.3/openbb_charting/charts}/generic_charts.py +4 -7
- {openbb_charting-2.1.2/openbb_charting/utils → openbb_charting-2.1.3/openbb_charting/charts}/helpers.py +11 -11
- openbb_charting-2.1.3/openbb_charting/charts/price_historical.py +314 -0
- openbb_charting-2.1.3/openbb_charting/charts/price_performance.py +106 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/base.py +1 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/pyproject.toml +1 -1
- openbb_charting-2.1.2/openbb_charting/builder.py +0 -53
- openbb_charting-2.1.2/openbb_charting/charting_router.py +0 -1446
- {openbb_charting-2.1.2/openbb_charting/utils → openbb_charting-2.1.3/openbb_charting/charts}/__init__.py +0 -0
- {openbb_charting-2.1.2/openbb_charting/utils → openbb_charting-2.1.3/openbb_charting/charts}/relative_rotation.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/__init__.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/assets/Terminal_icon.png +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/assets/plotly-2.32.0.min.js +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/backend.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/chart_style.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/config/__init__.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/config/openbb_styles.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/dummy_backend.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/openbb_figure.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly.html +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/__init__.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/data_classes.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/plugins/__init__.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/plugins/custom_indicators_plugin.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/plugins/momentum_plugin.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/plugins/overlap_plugin.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/plugins/trend_indicators_plugin.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/plugins/volatility_plugin.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/plugins/volume_plugin.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/ta_class.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/plotly_ta/ta_helpers.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/table.html +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/core/to_chart.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/query_params.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/styles/__init__.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/styles/colors.py +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/styles/default/dark.pltstyle.json +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/styles/default/light.pltstyle.json +0 -0
- {openbb_charting-2.1.2 → openbb_charting-2.1.3}/openbb_charting/styles/default/tables.pltstyle.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: openbb-charting
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.3
|
|
4
4
|
Summary: Charting extension for OpenBB
|
|
5
5
|
License: AGPL-3.0-only
|
|
6
6
|
Author: OpenBB Team
|
|
@@ -32,7 +32,7 @@ The library includes:
|
|
|
32
32
|
- prebuilt charts for a set of commands that are built-in OpenBB extensions
|
|
33
33
|
|
|
34
34
|
>[!NOTE]
|
|
35
|
-
> The charting library is an
|
|
35
|
+
> The charting library is an `OBBject` extension which means you'll have the functionality it exposes on every command result.
|
|
36
36
|
|
|
37
37
|
## Installation
|
|
38
38
|
|
|
@@ -143,15 +143,44 @@ Example usage:
|
|
|
143
143
|
|
|
144
144
|
## Add a visualization to an existing Platform command
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
To add a visualization to an existing command, you'll need to add a `poetry` plugin to your `pyproject.toml` file. The syntax should be the following:
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
```toml
|
|
149
|
+
[tool.poetry.plugins."openbb_charting_extension"]
|
|
150
|
+
my_extension = "openbb_my_extension.my_extension_views:MyExtensionViews"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Where the `openbb_charting_extension` is **mandatory**, otherwise the charting extension won't be able to find the visualization.
|
|
154
|
+
|
|
155
|
+
And the suggested structure for the `my_extension_views` module is the following:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
"""Views for MyExtension."""
|
|
159
|
+
|
|
160
|
+
from typing import Any, Dict, Tuple
|
|
161
|
+
|
|
162
|
+
from openbb_charting.charts.price_historical import price_historical
|
|
163
|
+
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class MyExtensionViews:
|
|
167
|
+
"""MyExtension Views."""
|
|
168
|
+
|
|
169
|
+
@staticmethod
|
|
170
|
+
def my_extension_price_historical(
|
|
171
|
+
**kwargs,
|
|
172
|
+
) -> Tuple[OpenBBFigure, Dict[str, Any]]:
|
|
173
|
+
"""MyExtension Price Historical Chart."""
|
|
174
|
+
return price_historical(**kwargs)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
> Note that `my_extension_views` lives under the `openbb_my_extension` package.
|
|
150
178
|
|
|
151
|
-
Afterwards, you'll need to add the visualization to
|
|
179
|
+
Afterwards, you'll need to add the visualization to your new `MyExtensionViews` class. The convention to match the endpoint with the respective charting function is the following:
|
|
152
180
|
|
|
153
181
|
- `/equity/price/historical` -> `equity_price_historical`
|
|
154
182
|
- `/technical/ema` -> `technical_ema`
|
|
183
|
+
- `/my_extension/price_historical` -> `my_extension_price_historical`
|
|
155
184
|
|
|
156
185
|
When you spot the charting function on the charting router file, you can add the visualization to it.
|
|
157
186
|
|
|
@@ -9,7 +9,7 @@ The library includes:
|
|
|
9
9
|
- prebuilt charts for a set of commands that are built-in OpenBB extensions
|
|
10
10
|
|
|
11
11
|
>[!NOTE]
|
|
12
|
-
> The charting library is an
|
|
12
|
+
> The charting library is an `OBBject` extension which means you'll have the functionality it exposes on every command result.
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -120,15 +120,44 @@ Example usage:
|
|
|
120
120
|
|
|
121
121
|
## Add a visualization to an existing Platform command
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
To add a visualization to an existing command, you'll need to add a `poetry` plugin to your `pyproject.toml` file. The syntax should be the following:
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
```toml
|
|
126
|
+
[tool.poetry.plugins."openbb_charting_extension"]
|
|
127
|
+
my_extension = "openbb_my_extension.my_extension_views:MyExtensionViews"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Where the `openbb_charting_extension` is **mandatory**, otherwise the charting extension won't be able to find the visualization.
|
|
131
|
+
|
|
132
|
+
And the suggested structure for the `my_extension_views` module is the following:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
"""Views for MyExtension."""
|
|
136
|
+
|
|
137
|
+
from typing import Any, Dict, Tuple
|
|
138
|
+
|
|
139
|
+
from openbb_charting.charts.price_historical import price_historical
|
|
140
|
+
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class MyExtensionViews:
|
|
144
|
+
"""MyExtension Views."""
|
|
145
|
+
|
|
146
|
+
@staticmethod
|
|
147
|
+
def my_extension_price_historical(
|
|
148
|
+
**kwargs,
|
|
149
|
+
) -> Tuple[OpenBBFigure, Dict[str, Any]]:
|
|
150
|
+
"""MyExtension Price Historical Chart."""
|
|
151
|
+
return price_historical(**kwargs)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
> Note that `my_extension_views` lives under the `openbb_my_extension` package.
|
|
127
155
|
|
|
128
|
-
Afterwards, you'll need to add the visualization to
|
|
156
|
+
Afterwards, you'll need to add the visualization to your new `MyExtensionViews` class. The convention to match the endpoint with the respective charting function is the following:
|
|
129
157
|
|
|
130
158
|
- `/equity/price/historical` -> `equity_price_historical`
|
|
131
159
|
- `/technical/ema` -> `technical_ema`
|
|
160
|
+
- `/my_extension/price_historical` -> `my_extension_price_historical`
|
|
132
161
|
|
|
133
162
|
When you spot the charting function on the charting router file, you can add the visualization to it.
|
|
134
163
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""OpenBB OBBject extension for charting."""
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
5
|
+
from openbb_core.app.model.extension import Extension
|
|
6
|
+
|
|
7
|
+
from openbb_charting.charting import Charting as _Charting
|
|
8
|
+
|
|
9
|
+
warnings.filterwarnings(
|
|
10
|
+
"ignore", category=UserWarning, module="openbb_core.app.model.extension", lineno=47
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
ext = Extension(name="charting", description="Create custom charts from OBBject data.")
|
|
14
|
+
Charting = ext.obbject_accessor(_Charting)
|
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Charting Class implementation."""
|
|
2
2
|
|
|
3
3
|
# pylint: disable=too-many-arguments,unused-argument
|
|
4
4
|
|
|
5
|
-
import warnings
|
|
6
5
|
from typing import (
|
|
7
6
|
Any,
|
|
8
7
|
Callable,
|
|
8
|
+
ClassVar,
|
|
9
9
|
Dict,
|
|
10
10
|
List,
|
|
11
11
|
Literal,
|
|
12
12
|
Optional,
|
|
13
13
|
Tuple,
|
|
14
|
+
Type,
|
|
14
15
|
Union,
|
|
15
16
|
)
|
|
16
17
|
from warnings import warn
|
|
17
18
|
|
|
18
19
|
import numpy as np
|
|
19
20
|
import pandas as pd
|
|
21
|
+
from importlib_metadata import entry_points
|
|
20
22
|
from openbb_core.app.model.charts.chart import Chart
|
|
21
|
-
from openbb_core.app.model.extension import Extension
|
|
22
23
|
from openbb_core.app.model.obbject import OBBject
|
|
23
24
|
from openbb_core.app.utils import basemodel_to_df, convert_to_basemodel
|
|
24
25
|
from openbb_core.provider.abstract.data import Data
|
|
25
26
|
from plotly.graph_objs import Figure
|
|
26
27
|
|
|
27
|
-
from openbb_charting import
|
|
28
|
+
from openbb_charting.charts.generic_charts import bar_chart, line_chart
|
|
29
|
+
from openbb_charting.charts.helpers import (
|
|
30
|
+
get_charting_functions,
|
|
31
|
+
get_charting_functions_list,
|
|
32
|
+
)
|
|
28
33
|
from openbb_charting.core.backend import Backend, create_backend, get_backend
|
|
29
34
|
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
30
35
|
from openbb_charting.query_params import ChartParams, IndicatorsParams
|
|
31
|
-
from openbb_charting.utils.generic_charts import bar_chart, line_chart
|
|
32
|
-
from openbb_charting.utils.helpers import get_charting_functions
|
|
33
|
-
|
|
34
|
-
warnings.filterwarnings(
|
|
35
|
-
"ignore", category=UserWarning, module="openbb_core.app.model.extension", lineno=47
|
|
36
|
-
)
|
|
37
36
|
|
|
38
|
-
ext = Extension(name="charting", description="Create custom charts from OBBject data.")
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
@ext.obbject_accessor
|
|
42
38
|
class Charting:
|
|
43
39
|
"""Charting extension.
|
|
44
40
|
|
|
@@ -64,6 +60,11 @@ class Charting:
|
|
|
64
60
|
Toggle the chart style, of an existing chart, between light and dark mode.
|
|
65
61
|
"""
|
|
66
62
|
|
|
63
|
+
_extension_views: ClassVar[List[Type]] = [
|
|
64
|
+
entry_point.load()
|
|
65
|
+
for entry_point in entry_points(group="openbb_charting_extension")
|
|
66
|
+
]
|
|
67
|
+
|
|
67
68
|
def __init__(self, obbject):
|
|
68
69
|
"""Initialize Charting extension."""
|
|
69
70
|
# pylint: disable=import-outside-toplevel
|
|
@@ -75,6 +76,7 @@ class Charting:
|
|
|
75
76
|
system_settings=self._obbject._system_settings, # type: ignore
|
|
76
77
|
)
|
|
77
78
|
self._backend: Backend = self._handle_backend()
|
|
79
|
+
self._functions: Dict[str, Callable] = self._get_functions()
|
|
78
80
|
|
|
79
81
|
@classmethod
|
|
80
82
|
def indicators(cls):
|
|
@@ -85,9 +87,21 @@ class Charting:
|
|
|
85
87
|
return IndicatorsParams()
|
|
86
88
|
|
|
87
89
|
@classmethod
|
|
88
|
-
def functions(cls):
|
|
90
|
+
def functions(cls) -> List[str]:
|
|
89
91
|
"""Return a list of the available functions."""
|
|
90
|
-
|
|
92
|
+
functions: List[str] = []
|
|
93
|
+
for view in cls._extension_views:
|
|
94
|
+
functions.extend(get_charting_functions_list(view))
|
|
95
|
+
|
|
96
|
+
return functions
|
|
97
|
+
|
|
98
|
+
def _get_functions(self) -> Dict[str, Callable]:
|
|
99
|
+
"""Return a dict with the available functions."""
|
|
100
|
+
functions: Dict[str, Callable] = {}
|
|
101
|
+
for view in self._extension_views:
|
|
102
|
+
functions.update(get_charting_functions(view))
|
|
103
|
+
|
|
104
|
+
return functions
|
|
91
105
|
|
|
92
106
|
def _handle_backend(self) -> Backend:
|
|
93
107
|
"""Create and start the backend."""
|
|
@@ -96,13 +110,16 @@ class Charting:
|
|
|
96
110
|
backend.start(debug=self._charting_settings.debug_mode)
|
|
97
111
|
return backend
|
|
98
112
|
|
|
99
|
-
|
|
100
|
-
def _get_chart_function(route: str) -> Callable:
|
|
113
|
+
def _get_chart_function(self, route: str) -> Callable:
|
|
101
114
|
"""Given a route, it returns the chart function. The module must contain the given route."""
|
|
102
115
|
if route is None:
|
|
103
116
|
raise ValueError("OBBject was initialized with no function route.")
|
|
104
117
|
adjusted_route = route.replace("/", "_")[1:]
|
|
105
|
-
|
|
118
|
+
if adjusted_route not in self._functions:
|
|
119
|
+
raise ValueError(
|
|
120
|
+
f"Could not find the route `{adjusted_route}` in the charting functions."
|
|
121
|
+
)
|
|
122
|
+
return self._functions[adjusted_route]
|
|
106
123
|
|
|
107
124
|
def get_params(self) -> ChartParams:
|
|
108
125
|
"""Return the ChartQueryParams class for the function the OBBject was created from.
|
|
@@ -326,28 +343,19 @@ class Charting:
|
|
|
326
343
|
self._obbject._route # pylint: disable=protected-access
|
|
327
344
|
)
|
|
328
345
|
kwargs["obbject_item"] = self._obbject.results
|
|
329
|
-
kwargs["charting_settings"] = self._charting_settings
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
kwargs["
|
|
338
|
-
self._obbject.provider
|
|
339
|
-
) # pylint: disable=protected-access
|
|
340
|
-
kwargs["extra"] = self._obbject.extra # pylint: disable=protected-access
|
|
341
|
-
|
|
342
|
-
if "kwargs" in kwargs:
|
|
343
|
-
_kwargs = kwargs.pop("kwargs")
|
|
344
|
-
kwargs.update(_kwargs.get("chart_params", {}))
|
|
346
|
+
kwargs["charting_settings"] = self._charting_settings #
|
|
347
|
+
kwargs["standard_params"] = (
|
|
348
|
+
self._obbject._standard_params # pylint: disable=protected-access
|
|
349
|
+
)
|
|
350
|
+
kwargs["extra_params"] = (
|
|
351
|
+
self._obbject._extra_params # pylint: disable=protected-access
|
|
352
|
+
)
|
|
353
|
+
kwargs["provider"] = self._obbject.provider
|
|
354
|
+
kwargs["extra"] = self._obbject.extra
|
|
345
355
|
fig, content = charting_function(**kwargs)
|
|
346
356
|
fig = self._set_chart_style(fig)
|
|
347
357
|
content = fig.show(external=True, **kwargs).to_plotly_json()
|
|
348
|
-
self._obbject.chart = Chart(
|
|
349
|
-
fig=fig, content=content, format=charting_router.CHART_FORMAT
|
|
350
|
-
)
|
|
358
|
+
self._obbject.chart = Chart(fig=fig, content=content)
|
|
351
359
|
if render:
|
|
352
360
|
fig.show(**kwargs)
|
|
353
361
|
except Exception: # pylint: disable=W0718
|
|
@@ -355,9 +363,7 @@ class Charting:
|
|
|
355
363
|
fig = self.create_line_chart(data=self._obbject.results, render=False, **kwargs) # type: ignore
|
|
356
364
|
fig = self._set_chart_style(fig)
|
|
357
365
|
content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
|
|
358
|
-
self._obbject.chart = Chart(
|
|
359
|
-
fig=fig, content=content, format=charting_router.CHART_FORMAT
|
|
360
|
-
)
|
|
366
|
+
self._obbject.chart = Chart(fig=fig, content=content)
|
|
361
367
|
if render:
|
|
362
368
|
return fig.show(**kwargs) # type: ignore
|
|
363
369
|
except Exception as e:
|
|
@@ -450,22 +456,14 @@ class Charting:
|
|
|
450
456
|
kwargs["index"] = index
|
|
451
457
|
kwargs["obbject_item"] = self._obbject.results
|
|
452
458
|
kwargs["charting_settings"] = self._charting_settings
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
):
|
|
457
|
-
kwargs["standard_params"] = (
|
|
458
|
-
self._obbject._standard_params.__dict__ # pylint: disable=protected-access
|
|
459
|
-
)
|
|
460
|
-
kwargs["provider"] = self._obbject.provider # pylint: disable=protected-access
|
|
461
|
-
kwargs["extra"] = self._obbject.extra # pylint: disable=protected-access
|
|
462
|
-
metadata = kwargs["extra"].get("metadata")
|
|
459
|
+
kwargs["standard_params"] = (
|
|
460
|
+
self._obbject._standard_params # pylint: disable=protected-access
|
|
461
|
+
)
|
|
463
462
|
kwargs["extra_params"] = (
|
|
464
|
-
|
|
463
|
+
self._obbject._extra_params # pylint: disable=protected-access
|
|
465
464
|
)
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
kwargs.update(_kwargs.get("chart_params", {}))
|
|
465
|
+
kwargs["provider"] = self._obbject.provider # pylint: disable=protected-access
|
|
466
|
+
kwargs["extra"] = self._obbject.extra # pylint: disable=protected-access
|
|
469
467
|
try:
|
|
470
468
|
if has_data:
|
|
471
469
|
self.show(data=data_as_df, render=render, **kwargs)
|
|
@@ -476,9 +474,7 @@ class Charting:
|
|
|
476
474
|
fig = self.create_line_chart(data=data_as_df, render=False, **kwargs)
|
|
477
475
|
fig = self._set_chart_style(fig)
|
|
478
476
|
content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
|
|
479
|
-
self._obbject.chart = Chart(
|
|
480
|
-
fig=fig, content=content, format=charting_router.CHART_FORMAT
|
|
481
|
-
)
|
|
477
|
+
self._obbject.chart = Chart(fig=fig, content=content)
|
|
482
478
|
if render:
|
|
483
479
|
return fig.show(**kwargs) # type: ignore
|
|
484
480
|
except Exception as e: # pylint: disable=W0718
|
|
@@ -488,7 +484,7 @@ class Charting:
|
|
|
488
484
|
|
|
489
485
|
def _set_chart_style(self, figure: Figure):
|
|
490
486
|
"""Set the user preference for light or dark mode."""
|
|
491
|
-
style = self._charting_settings.chart_style
|
|
487
|
+
style = self._charting_settings.chart_style
|
|
492
488
|
font_color = "black" if style == "light" else "white"
|
|
493
489
|
paper_bgcolor = "white" if style == "light" else "black"
|
|
494
490
|
figure = figure.update_layout(
|
|
@@ -498,7 +494,7 @@ class Charting:
|
|
|
498
494
|
)
|
|
499
495
|
return figure
|
|
500
496
|
|
|
501
|
-
def toggle_chart_style(self):
|
|
497
|
+
def toggle_chart_style(self):
|
|
502
498
|
"""Toggle the chart style between light and dark mode."""
|
|
503
499
|
if not hasattr(self._obbject.chart, "fig"):
|
|
504
500
|
raise ValueError(
|
|
@@ -10,14 +10,14 @@ from openbb_core.app.utils import basemodel_to_df, convert_to_basemodel
|
|
|
10
10
|
from openbb_core.provider.abstract.data import Data
|
|
11
11
|
from plotly.graph_objs import Figure
|
|
12
12
|
|
|
13
|
-
from openbb_charting.
|
|
14
|
-
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
15
|
-
from openbb_charting.styles.colors import LARGE_CYCLER
|
|
16
|
-
from openbb_charting.utils.helpers import (
|
|
13
|
+
from openbb_charting.charts.helpers import (
|
|
17
14
|
calculate_returns,
|
|
18
15
|
should_share_axis,
|
|
19
16
|
z_score_standardization,
|
|
20
17
|
)
|
|
18
|
+
from openbb_charting.core.chart_style import ChartStyle
|
|
19
|
+
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
20
|
+
from openbb_charting.styles.colors import LARGE_CYCLER
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def line_chart( # noqa: PLR0912
|
|
@@ -48,7 +48,6 @@ def line_chart( # noqa: PLR0912
|
|
|
48
48
|
**kwargs,
|
|
49
49
|
) -> Union[OpenBBFigure, Figure]:
|
|
50
50
|
"""Create a line chart."""
|
|
51
|
-
|
|
52
51
|
if data is None:
|
|
53
52
|
raise ValueError("Error: Data is a required field.")
|
|
54
53
|
|
|
@@ -381,7 +380,6 @@ def bar_chart( # noqa: PLR0912
|
|
|
381
380
|
OpenBBFigure
|
|
382
381
|
The OpenBBFigure object.
|
|
383
382
|
"""
|
|
384
|
-
|
|
385
383
|
try:
|
|
386
384
|
figure = OpenBBFigure()
|
|
387
385
|
except Exception as _:
|
|
@@ -523,7 +521,6 @@ def bar_increasing_decreasing( # pylint: disable=W0102
|
|
|
523
521
|
OpenBBFigure
|
|
524
522
|
The OpenBBFigure object.
|
|
525
523
|
"""
|
|
526
|
-
|
|
527
524
|
try:
|
|
528
525
|
figure = OpenBBFigure()
|
|
529
526
|
except Exception as _:
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"""Helper functions for charting."""
|
|
2
2
|
|
|
3
|
-
import importlib
|
|
4
3
|
from inspect import getmembers, getsource, isfunction
|
|
5
|
-
from typing import List
|
|
4
|
+
from typing import Callable, Dict, List, Type
|
|
6
5
|
|
|
7
6
|
import pandas as pd
|
|
8
7
|
from pandas_ta import candles
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
def get_charting_functions() ->
|
|
10
|
+
def get_charting_functions(view: Type) -> Dict[str, Callable]:
|
|
12
11
|
"""Discover charting functions."""
|
|
12
|
+
implemented_functions: Dict[str, Callable] = {}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
implemented_functions = []
|
|
17
|
-
|
|
18
|
-
for name, obj in getmembers(charting_router, isfunction):
|
|
14
|
+
for name, obj in getmembers(view, isfunction):
|
|
19
15
|
if (
|
|
20
|
-
obj.__module__ ==
|
|
16
|
+
obj.__module__ == view.__module__
|
|
21
17
|
and not name.startswith("_")
|
|
22
18
|
and "NotImplementedError" not in getsource(obj)
|
|
23
19
|
):
|
|
24
|
-
implemented_functions
|
|
20
|
+
implemented_functions[name] = obj
|
|
25
21
|
|
|
26
22
|
return implemented_functions
|
|
27
23
|
|
|
28
24
|
|
|
25
|
+
def get_charting_functions_list(view: Type) -> List[str]:
|
|
26
|
+
"""Get a list of all the charting functions."""
|
|
27
|
+
return list(get_charting_functions(view).keys())
|
|
28
|
+
|
|
29
|
+
|
|
29
30
|
def z_score_standardization(data: pd.Series) -> pd.Series:
|
|
30
31
|
"""Z-Score Standardization Method."""
|
|
31
32
|
return (data - data.mean()) / data.std()
|
|
@@ -68,7 +69,6 @@ def heikin_ashi(data: pd.DataFrame) -> pd.DataFrame:
|
|
|
68
69
|
pd.DataFrame
|
|
69
70
|
DataFrame copy with Heikin Ashi candle calculations.
|
|
70
71
|
"""
|
|
71
|
-
|
|
72
72
|
df = data.copy()
|
|
73
73
|
|
|
74
74
|
check_columns = ["open", "high", "low", "close"]
|