openbb-charting 2.3.5__tar.gz → 2.4.1__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.3.5 → openbb_charting-2.4.1}/PKG-INFO +7 -6
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charting.py +113 -75
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charts/correlation_matrix.py +2 -10
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charts/generic_charts.py +37 -63
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charts/helpers.py +6 -7
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charts/price_historical.py +5 -19
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charts/price_performance.py +5 -4
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charts/relative_rotation.py +2 -3
- openbb_charting-2.4.1/openbb_charting/core/assets/plotly-3.1.0.min.js +3882 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/backend.py +22 -22
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/chart_style.py +17 -14
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/config/openbb_styles.py +4 -4
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/dummy_backend.py +2 -3
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/openbb_figure.py +91 -98
- openbb_charting-2.4.1/openbb_charting/core/plotly.html +4031 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/base.py +21 -25
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/data_classes.py +22 -22
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/plugins/custom_indicators_plugin.py +5 -1
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/plugins/momentum_plugin.py +3 -8
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/ta_class.py +25 -30
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/ta_helpers.py +3 -4
- openbb_charting-2.4.1/openbb_charting/core/table.html +165 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/to_chart.py +5 -5
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/query_params.py +49 -49
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/pyproject.toml +5 -5
- openbb_charting-2.3.5/openbb_charting/core/assets/plotly-3.0.0.min.js +0 -3879
- openbb_charting-2.3.5/openbb_charting/core/plotly.html +0 -4028
- openbb_charting-2.3.5/openbb_charting/core/table.html +0 -171
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/README.md +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/__init__.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charts/__init__.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/__init__.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/assets/Terminal_icon.png +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/config/__init__.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/__init__.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/plugins/__init__.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/plugins/overlap_plugin.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/plugins/trend_indicators_plugin.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/plugins/volatility_plugin.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/core/plotly_ta/plugins/volume_plugin.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/styles/__init__.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/styles/colors.py +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/styles/default/dark.pltstyle.json +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/styles/default/light.pltstyle.json +0 -0
- {openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/styles/default/tables.pltstyle.json +0 -0
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: openbb-charting
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.1
|
|
4
4
|
Summary: Charting extension for OpenBB
|
|
5
5
|
License: AGPL-3.0-only
|
|
6
6
|
Author: OpenBB Team
|
|
7
7
|
Author-email: hello@openbb.co
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.10,<3.14
|
|
9
9
|
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
15
|
Provides-Extra: pywry
|
|
15
16
|
Requires-Dist: nbformat (>=5.10.0,<6.0.0)
|
|
16
|
-
Requires-Dist: openbb-core (>=1.
|
|
17
|
-
Requires-Dist: pandas-ta-openbb (>=0.4.
|
|
18
|
-
Requires-Dist: plotly (>=6.
|
|
17
|
+
Requires-Dist: openbb-core (>=1.5.7,<2.0.0)
|
|
18
|
+
Requires-Dist: pandas-ta-openbb (>=0.4.22,<0.5.0)
|
|
19
|
+
Requires-Dist: plotly (>=6.3.1,<7.0.0)
|
|
19
20
|
Requires-Dist: pywry (>=0.6.2,<0.7.0) ; extra == "pywry"
|
|
20
21
|
Description-Content-Type: text/markdown
|
|
21
22
|
|
|
@@ -2,17 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# pylint: disable=too-many-arguments,unused-argument,too-many-positional-arguments
|
|
4
4
|
|
|
5
|
+
from collections.abc import Callable
|
|
5
6
|
from typing import (
|
|
6
7
|
TYPE_CHECKING,
|
|
7
8
|
Any,
|
|
8
|
-
Callable,
|
|
9
9
|
ClassVar,
|
|
10
|
-
Dict,
|
|
11
|
-
List,
|
|
12
10
|
Literal,
|
|
13
|
-
Optional,
|
|
14
|
-
Tuple,
|
|
15
|
-
Type,
|
|
16
11
|
Union,
|
|
17
12
|
)
|
|
18
13
|
from warnings import warn
|
|
@@ -30,11 +25,11 @@ from openbb_charting.charts.helpers import (
|
|
|
30
25
|
|
|
31
26
|
if TYPE_CHECKING:
|
|
32
27
|
from numpy import ndarray # noqa
|
|
33
|
-
from pandas import DataFrame, Series
|
|
34
|
-
from plotly.graph_objs import Figure
|
|
35
|
-
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
36
|
-
from openbb_charting.query_params import ChartParams
|
|
37
|
-
from openbb_charting.core.backend import Backend
|
|
28
|
+
from pandas import DataFrame, Series
|
|
29
|
+
from plotly.graph_objs import Figure
|
|
30
|
+
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
31
|
+
from openbb_charting.query_params import ChartParams
|
|
32
|
+
from openbb_charting.core.backend import Backend
|
|
38
33
|
|
|
39
34
|
|
|
40
35
|
class Charting:
|
|
@@ -64,7 +59,7 @@ class Charting:
|
|
|
64
59
|
Toggle the chart style, of an existing chart, between light and dark mode.
|
|
65
60
|
"""
|
|
66
61
|
|
|
67
|
-
_extension_views: ClassVar[
|
|
62
|
+
_extension_views: ClassVar[list[type]] = [
|
|
68
63
|
entry_point.load()
|
|
69
64
|
for entry_point in entry_points(group="openbb_charting_extension")
|
|
70
65
|
]
|
|
@@ -86,7 +81,7 @@ class Charting:
|
|
|
86
81
|
system_settings=self._obbject._system_settings, # type: ignore
|
|
87
82
|
)
|
|
88
83
|
self._backend = self._handle_backend()
|
|
89
|
-
self._functions:
|
|
84
|
+
self._functions: dict[str, Callable] = self._get_functions()
|
|
90
85
|
|
|
91
86
|
@classmethod
|
|
92
87
|
def indicators(cls):
|
|
@@ -100,17 +95,17 @@ class Charting:
|
|
|
100
95
|
return IndicatorsParams()
|
|
101
96
|
|
|
102
97
|
@classmethod
|
|
103
|
-
def functions(cls) ->
|
|
98
|
+
def functions(cls) -> list[str]:
|
|
104
99
|
"""Return a list of the available functions."""
|
|
105
|
-
functions:
|
|
100
|
+
functions: list[str] = []
|
|
106
101
|
for view in cls._extension_views:
|
|
107
102
|
functions.extend(get_charting_functions_list(view))
|
|
108
103
|
|
|
109
104
|
return functions
|
|
110
105
|
|
|
111
|
-
def _get_functions(self) ->
|
|
106
|
+
def _get_functions(self) -> dict[str, Callable]:
|
|
112
107
|
"""Return a dict with the available functions."""
|
|
113
|
-
functions:
|
|
108
|
+
functions: dict[str, Callable] = {}
|
|
114
109
|
for view in self._extension_views:
|
|
115
110
|
functions.update(get_charting_functions(view))
|
|
116
111
|
|
|
@@ -156,23 +151,21 @@ class Charting:
|
|
|
156
151
|
|
|
157
152
|
return help( # type: ignore
|
|
158
153
|
self._get_chart_function( # pylint: disable=protected-access
|
|
159
|
-
self._obbject.extra[
|
|
154
|
+
self._obbject.extra[
|
|
160
155
|
"metadata"
|
|
161
|
-
].route
|
|
156
|
+
].route # pylint: disable=protected-access
|
|
162
157
|
)
|
|
163
158
|
)
|
|
164
159
|
|
|
165
160
|
def _prepare_data_as_df(
|
|
166
|
-
self, data:
|
|
167
|
-
) ->
|
|
161
|
+
self, data: Union["DataFrame", "Series"] | None
|
|
162
|
+
) -> tuple["DataFrame", bool]:
|
|
168
163
|
"""Convert supplied data to a DataFrame."""
|
|
169
164
|
# pylint: disable=import-outside-toplevel
|
|
170
165
|
from openbb_core.app.utils import basemodel_to_df, convert_to_basemodel
|
|
171
166
|
from pandas import DataFrame, Series
|
|
172
167
|
|
|
173
|
-
has_data = (
|
|
174
|
-
isinstance(data, (Data, DataFrame, Series)) and not data.empty # type: ignore
|
|
175
|
-
) or (bool(data))
|
|
168
|
+
has_data = (isinstance(data, (Data, DataFrame, Series)) and not data.empty) or (bool(data)) # type: ignore
|
|
176
169
|
index = (
|
|
177
170
|
data.index.name
|
|
178
171
|
if has_data and isinstance(data, (DataFrame, Series))
|
|
@@ -196,23 +189,23 @@ class Charting:
|
|
|
196
189
|
list,
|
|
197
190
|
dict,
|
|
198
191
|
"DataFrame",
|
|
199
|
-
|
|
192
|
+
list["DataFrame"],
|
|
200
193
|
"Series",
|
|
201
|
-
|
|
194
|
+
list["Series"],
|
|
202
195
|
"ndarray",
|
|
203
196
|
Data,
|
|
204
197
|
],
|
|
205
|
-
index:
|
|
206
|
-
target:
|
|
207
|
-
title:
|
|
208
|
-
x:
|
|
209
|
-
xtitle:
|
|
210
|
-
y:
|
|
211
|
-
ytitle:
|
|
212
|
-
y2:
|
|
213
|
-
y2title:
|
|
214
|
-
layout_kwargs:
|
|
215
|
-
scatter_kwargs:
|
|
198
|
+
index: str | None = None,
|
|
199
|
+
target: str | None = None,
|
|
200
|
+
title: str | None = None,
|
|
201
|
+
x: str | None = None,
|
|
202
|
+
xtitle: str | None = None,
|
|
203
|
+
y: str | list[str] | None = None,
|
|
204
|
+
ytitle: str | None = None,
|
|
205
|
+
y2: str | list[str] | None = None,
|
|
206
|
+
y2title: str | None = None,
|
|
207
|
+
layout_kwargs: dict | None = None,
|
|
208
|
+
scatter_kwargs: dict | None = None,
|
|
216
209
|
normalize: bool = False,
|
|
217
210
|
returns: bool = False,
|
|
218
211
|
same_axis: bool = False,
|
|
@@ -294,25 +287,25 @@ class Charting:
|
|
|
294
287
|
list,
|
|
295
288
|
dict,
|
|
296
289
|
"DataFrame",
|
|
297
|
-
|
|
290
|
+
list["DataFrame"],
|
|
298
291
|
"Series",
|
|
299
|
-
|
|
292
|
+
list["Series"],
|
|
300
293
|
"ndarray",
|
|
301
294
|
Data,
|
|
302
295
|
],
|
|
303
296
|
x: str,
|
|
304
|
-
y:
|
|
297
|
+
y: str | list[str],
|
|
305
298
|
barmode: Literal["group", "stack", "relative", "overlay"] = "group",
|
|
306
299
|
xtype: Literal[
|
|
307
300
|
"category", "multicategory", "date", "log", "linear"
|
|
308
301
|
] = "category",
|
|
309
|
-
title:
|
|
310
|
-
xtitle:
|
|
311
|
-
ytitle:
|
|
302
|
+
title: str | None = None,
|
|
303
|
+
xtitle: str | None = None,
|
|
304
|
+
ytitle: str | None = None,
|
|
312
305
|
orientation: Literal["h", "v"] = "v",
|
|
313
|
-
colors:
|
|
314
|
-
layout_kwargs:
|
|
315
|
-
bar_kwargs:
|
|
306
|
+
colors: list[str] | None = None,
|
|
307
|
+
layout_kwargs: dict[str, Any] | None = None,
|
|
308
|
+
bar_kwargs: dict[str, Any] | None = None,
|
|
316
309
|
render: bool = True,
|
|
317
310
|
**kwargs,
|
|
318
311
|
) -> Union["OpenBBFigure", "Figure", None]:
|
|
@@ -375,13 +368,13 @@ class Charting:
|
|
|
375
368
|
X: "Series",
|
|
376
369
|
Y: "Series",
|
|
377
370
|
Z: "Series",
|
|
378
|
-
xtitle:
|
|
379
|
-
ytitle:
|
|
380
|
-
ztitle:
|
|
381
|
-
colorscale:
|
|
382
|
-
title:
|
|
383
|
-
layout_kwargs:
|
|
384
|
-
theme:
|
|
371
|
+
xtitle: str | None = "DTE",
|
|
372
|
+
ytitle: str | None = "Strike",
|
|
373
|
+
ztitle: str | None = "IV",
|
|
374
|
+
colorscale: str | list | None = None,
|
|
375
|
+
title: str | None = None,
|
|
376
|
+
layout_kwargs: dict[str, Any] | None = None,
|
|
377
|
+
theme: Literal["dark", "light"] | None = None,
|
|
385
378
|
) -> Union["OpenBBFigure", "Figure"]:
|
|
386
379
|
"""Create a 3D surface chart.
|
|
387
380
|
|
|
@@ -438,7 +431,7 @@ class Charting:
|
|
|
438
431
|
method: Literal["pearson", "kendall", "spearman"] = "pearson",
|
|
439
432
|
colorscale: str = "RdBu",
|
|
440
433
|
title: str = "Asset Correlation Matrix",
|
|
441
|
-
layout_kwargs:
|
|
434
|
+
layout_kwargs: dict[str, Any] | None = None,
|
|
442
435
|
):
|
|
443
436
|
"""Create a correlation matrix from external data.
|
|
444
437
|
|
|
@@ -479,23 +472,63 @@ class Charting:
|
|
|
479
472
|
|
|
480
473
|
def show(self, render: bool = True, **kwargs):
|
|
481
474
|
"""Display chart and save it to the OBBject."""
|
|
475
|
+
# pylint: disable=import-outside-toplevel
|
|
476
|
+
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
477
|
+
|
|
482
478
|
try:
|
|
483
479
|
charting_function = self._get_chart_function(
|
|
484
|
-
self._obbject._route # pylint: disable=protected-access
|
|
480
|
+
self._obbject._route # pylint: disable=protected-access # type: ignore
|
|
485
481
|
)
|
|
486
482
|
kwargs["obbject_item"] = self._obbject.results
|
|
487
483
|
kwargs["charting_settings"] = self._charting_settings
|
|
488
484
|
kwargs["standard_params"] = (
|
|
489
485
|
self._obbject._standard_params # pylint: disable=protected-access
|
|
490
486
|
)
|
|
491
|
-
kwargs
|
|
492
|
-
|
|
487
|
+
# If the provider interface isn't used, endpoint kwargs are already here.
|
|
488
|
+
# Don't overwrite them.
|
|
489
|
+
obb_kwargs = (
|
|
490
|
+
self._obbject._extra_params or {} # pylint: disable=protected-access
|
|
493
491
|
)
|
|
492
|
+
if obb_kwargs:
|
|
493
|
+
for k, v in obb_kwargs.items():
|
|
494
|
+
kwargs["extra_params"].update({k: v})
|
|
495
|
+
|
|
494
496
|
kwargs["provider"] = self._obbject.provider
|
|
495
497
|
kwargs["extra"] = self._obbject.extra
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
498
|
+
|
|
499
|
+
# Handle different types of output from the charting endpoint.
|
|
500
|
+
chart_response: Any = charting_function(**kwargs)
|
|
501
|
+
|
|
502
|
+
# If returned a Chart object, set as-is.
|
|
503
|
+
if isinstance(chart_response, Chart):
|
|
504
|
+
self._obbject.chart = chart_response
|
|
505
|
+
# If just an OpenBBFigure gets returned, create the serialized version for the API.
|
|
506
|
+
elif isinstance(chart_response, OpenBBFigure):
|
|
507
|
+
fig = chart_response
|
|
508
|
+
content = fig.show(external=True, **kwargs).to_plotly_json()
|
|
509
|
+
self._obbject.chart = Chart(
|
|
510
|
+
fig=fig, content=content, format=self._format
|
|
511
|
+
)
|
|
512
|
+
# Current functions return this.
|
|
513
|
+
elif isinstance(chart_response, tuple) and len(chart_response) == 2:
|
|
514
|
+
fig, content = chart_response
|
|
515
|
+
|
|
516
|
+
if isinstance(fig, OpenBBFigure):
|
|
517
|
+
content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
|
|
518
|
+
self._obbject.chart = Chart(
|
|
519
|
+
fig=fig, content=content, format=self._format
|
|
520
|
+
)
|
|
521
|
+
else:
|
|
522
|
+
self._obbject.chart = Chart(
|
|
523
|
+
fig=fig, content=content, format=type(fig).__name__
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
else:
|
|
527
|
+
self._obbject.chart = Chart(
|
|
528
|
+
fig=chart_response, content=None, format="unknown"
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
if render and hasattr(fig, "show"):
|
|
499
532
|
fig.show(**kwargs)
|
|
500
533
|
|
|
501
534
|
except (RuntimeError, OpenBBError) as e:
|
|
@@ -520,21 +553,22 @@ class Charting:
|
|
|
520
553
|
# pylint: disable=too-many-locals,inconsistent-return-statements
|
|
521
554
|
def to_chart(
|
|
522
555
|
self,
|
|
523
|
-
data:
|
|
556
|
+
data: (
|
|
524
557
|
Union[
|
|
525
558
|
list,
|
|
526
559
|
dict,
|
|
527
560
|
"DataFrame",
|
|
528
|
-
|
|
561
|
+
list["DataFrame"],
|
|
529
562
|
"Series",
|
|
530
|
-
|
|
563
|
+
list["Series"],
|
|
531
564
|
"ndarray",
|
|
532
565
|
Data,
|
|
533
566
|
]
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
567
|
+
| None
|
|
568
|
+
) = None,
|
|
569
|
+
target: str | None = None,
|
|
570
|
+
index: str | None = None,
|
|
571
|
+
indicators: dict[str, dict[str, Any]] | None = None,
|
|
538
572
|
symbol: str = "",
|
|
539
573
|
candles: bool = True,
|
|
540
574
|
volume: bool = True,
|
|
@@ -635,11 +669,14 @@ class Charting:
|
|
|
635
669
|
style = self._charting_settings.chart_style
|
|
636
670
|
font_color = "black" if style == "light" else "white"
|
|
637
671
|
paper_bgcolor = "white" if style == "light" else "black"
|
|
672
|
+
plot_bgcolor = "white" if style == "light" else "black"
|
|
638
673
|
figure = figure.update_layout(
|
|
639
|
-
dict(
|
|
640
|
-
font_color=font_color,
|
|
674
|
+
dict(
|
|
675
|
+
font_color=font_color,
|
|
676
|
+
paper_bgcolor=paper_bgcolor,
|
|
677
|
+
plot_bgcolor=plot_bgcolor,
|
|
641
678
|
)
|
|
642
|
-
)
|
|
679
|
+
) # pylint: disable=R1735
|
|
643
680
|
return figure
|
|
644
681
|
|
|
645
682
|
def toggle_chart_style(self):
|
|
@@ -686,7 +723,7 @@ class Charting:
|
|
|
686
723
|
|
|
687
724
|
def table(
|
|
688
725
|
self,
|
|
689
|
-
data:
|
|
726
|
+
data: Union["DataFrame", "Series"] | None = None,
|
|
690
727
|
title: str = "",
|
|
691
728
|
):
|
|
692
729
|
"""Display an interactive table.
|
|
@@ -714,8 +751,9 @@ class Charting:
|
|
|
714
751
|
self._backend.send_table(
|
|
715
752
|
df_table=data_as_df,
|
|
716
753
|
title=title
|
|
717
|
-
or
|
|
718
|
-
|
|
754
|
+
or ""
|
|
755
|
+
or self._obbject._route, # pylint: disable=protected-access # type: ignore
|
|
756
|
+
theme=self._charting_settings.table_style, # pylint: disable=protected-access
|
|
719
757
|
)
|
|
720
758
|
except Exception as e: # pylint: disable=W0718
|
|
721
759
|
warn(f"Failed to show figure with backend. {e}")
|
|
@@ -733,8 +771,8 @@ class Charting:
|
|
|
733
771
|
self,
|
|
734
772
|
url: str,
|
|
735
773
|
title: str = "",
|
|
736
|
-
width:
|
|
737
|
-
height:
|
|
774
|
+
width: int | None = None,
|
|
775
|
+
height: int | None = None,
|
|
738
776
|
):
|
|
739
777
|
"""Return the URL of the chart."""
|
|
740
778
|
try:
|
{openbb_charting-2.3.5 → openbb_charting-2.4.1}/openbb_charting/charts/correlation_matrix.py
RENAMED
|
@@ -25,7 +25,8 @@ def correlation_matrix( # noqa: PLR0912
|
|
|
25
25
|
corr = basemodel_to_df(kwargs["data"], index=kwargs.get("index", "date")) # type: ignore
|
|
26
26
|
else:
|
|
27
27
|
corr = basemodel_to_df(
|
|
28
|
-
kwargs["obbject_item"],
|
|
28
|
+
kwargs["obbject_item"],
|
|
29
|
+
index=kwargs.get("index", "date"), # type: ignore
|
|
29
30
|
)
|
|
30
31
|
if (
|
|
31
32
|
"symbol" in corr.columns
|
|
@@ -100,15 +101,6 @@ def correlation_matrix( # noqa: PLR0912
|
|
|
100
101
|
)
|
|
101
102
|
fig = Figure(data=[heatmap], layout=layout)
|
|
102
103
|
figure = OpenBBFigure(fig=fig)
|
|
103
|
-
figure.update_layout(
|
|
104
|
-
font=dict(color=text_color),
|
|
105
|
-
paper_bgcolor=(
|
|
106
|
-
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
107
|
-
),
|
|
108
|
-
plot_bgcolor=(
|
|
109
|
-
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
110
|
-
),
|
|
111
|
-
)
|
|
112
104
|
layout_kwargs = kwargs.get("layout_kwargs", {})
|
|
113
105
|
|
|
114
106
|
if layout_kwargs:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# pylint: disable=too-many-arguments,unused-argument,too-many-locals, too-many-branches, too-many-lines, too-many-statements, use-dict-literal, broad-exception-caught, too-many-nested-blocks, too-many-positional-arguments
|
|
4
4
|
|
|
5
|
-
from typing import TYPE_CHECKING, Any,
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Literal, Union
|
|
6
6
|
|
|
7
7
|
from openbb_core.app.utils import basemodel_to_df, convert_to_basemodel
|
|
8
8
|
from openbb_core.provider.abstract.data import Data
|
|
@@ -27,23 +27,23 @@ def line_chart( # noqa: PLR0912
|
|
|
27
27
|
list,
|
|
28
28
|
dict,
|
|
29
29
|
"DataFrame",
|
|
30
|
-
|
|
30
|
+
list["DataFrame"],
|
|
31
31
|
"Series",
|
|
32
|
-
|
|
32
|
+
list["Series"],
|
|
33
33
|
"ndarray",
|
|
34
34
|
Data,
|
|
35
35
|
],
|
|
36
|
-
index:
|
|
37
|
-
target:
|
|
38
|
-
title:
|
|
39
|
-
x:
|
|
40
|
-
xtitle:
|
|
41
|
-
y:
|
|
42
|
-
ytitle:
|
|
43
|
-
y2:
|
|
44
|
-
y2title:
|
|
45
|
-
layout_kwargs:
|
|
46
|
-
scatter_kwargs:
|
|
36
|
+
index: str | None = None,
|
|
37
|
+
target: str | None = None,
|
|
38
|
+
title: str | None = None,
|
|
39
|
+
x: str | None = None,
|
|
40
|
+
xtitle: str | None = None,
|
|
41
|
+
y: str | list[str] | None = None,
|
|
42
|
+
ytitle: str | None = None,
|
|
43
|
+
y2: str | list[str] | None = None,
|
|
44
|
+
y2title: str | None = None,
|
|
45
|
+
layout_kwargs: dict | None = None,
|
|
46
|
+
scatter_kwargs: dict | None = None,
|
|
47
47
|
normalize: bool = False,
|
|
48
48
|
returns: bool = False,
|
|
49
49
|
same_axis: bool = False,
|
|
@@ -152,7 +152,6 @@ def line_chart( # noqa: PLR0912
|
|
|
152
152
|
df = df[sorted_columns] # type: ignore
|
|
153
153
|
|
|
154
154
|
for i, col in enumerate(df.columns):
|
|
155
|
-
|
|
156
155
|
if col in y: # type: ignore[operator]
|
|
157
156
|
hovertemplate = (
|
|
158
157
|
hovertemplate
|
|
@@ -247,12 +246,6 @@ def line_chart( # noqa: PLR0912
|
|
|
247
246
|
fig.update_layout(
|
|
248
247
|
title=dict(text=title if title else None, x=0.5, font=dict(size=16)),
|
|
249
248
|
font=dict(color=text_color),
|
|
250
|
-
paper_bgcolor=(
|
|
251
|
-
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
252
|
-
),
|
|
253
|
-
plot_bgcolor=(
|
|
254
|
-
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
255
|
-
),
|
|
256
249
|
legend=dict(
|
|
257
250
|
orientation="v",
|
|
258
251
|
yanchor="top",
|
|
@@ -346,23 +339,23 @@ def bar_chart( # noqa: PLR0912
|
|
|
346
339
|
list,
|
|
347
340
|
dict,
|
|
348
341
|
"DataFrame",
|
|
349
|
-
|
|
342
|
+
list["DataFrame"],
|
|
350
343
|
"Series",
|
|
351
|
-
|
|
344
|
+
list["Series"],
|
|
352
345
|
"ndarray",
|
|
353
346
|
Data,
|
|
354
347
|
],
|
|
355
348
|
x: str,
|
|
356
|
-
y:
|
|
349
|
+
y: str | list[str],
|
|
357
350
|
barmode: Literal["group", "stack", "relative", "overlay"] = "group",
|
|
358
351
|
xtype: Literal["category", "multicategory", "date", "log", "linear"] = "category",
|
|
359
|
-
title:
|
|
360
|
-
xtitle:
|
|
361
|
-
ytitle:
|
|
352
|
+
title: str | None = None,
|
|
353
|
+
xtitle: str | None = None,
|
|
354
|
+
ytitle: str | None = None,
|
|
362
355
|
orientation: Literal["h", "v"] = "v",
|
|
363
|
-
colors:
|
|
364
|
-
bar_kwargs:
|
|
365
|
-
layout_kwargs:
|
|
356
|
+
colors: list[str] | None = None,
|
|
357
|
+
bar_kwargs: dict[str, Any] | None = None,
|
|
358
|
+
layout_kwargs: dict[str, Any] | None = None,
|
|
366
359
|
**kwargs,
|
|
367
360
|
) -> Union["OpenBBFigure", "Figure"]:
|
|
368
361
|
"""Create a vertical bar chart on a single x-axis with one or more values for the y-axis.
|
|
@@ -457,12 +450,6 @@ def bar_chart( # noqa: PLR0912
|
|
|
457
450
|
|
|
458
451
|
figure.update_layout(
|
|
459
452
|
title=dict(text=title if title else None, x=0.5, font=dict(size=16)),
|
|
460
|
-
paper_bgcolor=(
|
|
461
|
-
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
462
|
-
),
|
|
463
|
-
plot_bgcolor=(
|
|
464
|
-
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
465
|
-
),
|
|
466
453
|
legend=dict(
|
|
467
454
|
orientation="v",
|
|
468
455
|
yanchor="top",
|
|
@@ -524,15 +511,15 @@ def bar_chart( # noqa: PLR0912
|
|
|
524
511
|
|
|
525
512
|
|
|
526
513
|
def bar_increasing_decreasing( # pylint: disable=W0102
|
|
527
|
-
keys:
|
|
528
|
-
values:
|
|
529
|
-
title:
|
|
530
|
-
xtitle:
|
|
531
|
-
ytitle:
|
|
532
|
-
colors:
|
|
514
|
+
keys: list[str],
|
|
515
|
+
values: list[int | float],
|
|
516
|
+
title: str | None = None,
|
|
517
|
+
xtitle: str | None = None,
|
|
518
|
+
ytitle: str | None = None,
|
|
519
|
+
colors: list[str] = ["blue", "red"],
|
|
533
520
|
orientation: Literal["h", "v"] = "h",
|
|
534
521
|
barmode: Literal["group", "stack", "relative", "overlay"] = "relative",
|
|
535
|
-
layout_kwargs:
|
|
522
|
+
layout_kwargs: dict[str, Any] | None = None,
|
|
536
523
|
) -> Union["OpenBBFigure", "Figure"]:
|
|
537
524
|
"""Create a bar chart with increasing and decreasing values represented by two colors.
|
|
538
525
|
|
|
@@ -638,12 +625,6 @@ def bar_increasing_decreasing( # pylint: disable=W0102
|
|
|
638
625
|
categoryorder="array" if orientation == "v" else None,
|
|
639
626
|
categoryarray=keys if orientation == "v" else None,
|
|
640
627
|
),
|
|
641
|
-
paper_bgcolor=(
|
|
642
|
-
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
643
|
-
),
|
|
644
|
-
plot_bgcolor=(
|
|
645
|
-
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
646
|
-
),
|
|
647
628
|
font=dict(color="white" if text_color == "white" else "black"),
|
|
648
629
|
margin=dict(pad=5),
|
|
649
630
|
)
|
|
@@ -660,13 +641,13 @@ def surface3d(
|
|
|
660
641
|
X: "Series",
|
|
661
642
|
Y: "Series",
|
|
662
643
|
Z: "Series",
|
|
663
|
-
xtitle:
|
|
664
|
-
ytitle:
|
|
665
|
-
ztitle:
|
|
666
|
-
colorscale:
|
|
667
|
-
title:
|
|
668
|
-
layout_kwargs:
|
|
669
|
-
theme:
|
|
644
|
+
xtitle: str | None = "DTE",
|
|
645
|
+
ytitle: str | None = "Strike",
|
|
646
|
+
ztitle: str | None = "IV",
|
|
647
|
+
colorscale: str | list | None = None,
|
|
648
|
+
title: str | None = None,
|
|
649
|
+
layout_kwargs: dict[str, Any] | None = None,
|
|
650
|
+
theme: Literal["dark", "light"] | None = None,
|
|
670
651
|
) -> Union["OpenBBFigure", "Figure"]:
|
|
671
652
|
"""Create a 3D surface chart.
|
|
672
653
|
|
|
@@ -803,14 +784,7 @@ def surface3d(
|
|
|
803
784
|
center=dict(x=-0.01, y=0, z=-0.3),
|
|
804
785
|
eye=dict(x=1.75, y=1.75, z=0.69),
|
|
805
786
|
),
|
|
806
|
-
paper_bgcolor=(
|
|
807
|
-
"rgba(21,21,21,1)" if text_color == "white" else "rgba(255,255,255,1)"
|
|
808
|
-
),
|
|
809
|
-
plot_bgcolor=(
|
|
810
|
-
"rgba(21,21,21,1)" if text_color == "white" else "rgba(255,255,255,1)"
|
|
811
|
-
),
|
|
812
787
|
font=dict(color=text_color),
|
|
813
|
-
# margin=dict(t=100, b=10, r=10, l=10),
|
|
814
788
|
)
|
|
815
789
|
|
|
816
790
|
fig.update_scenes(
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
# pylint: disable=R0917
|
|
4
4
|
|
|
5
|
-
from
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
6
7
|
|
|
7
8
|
if TYPE_CHECKING:
|
|
8
9
|
from pandas import DataFrame, Series
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
def get_charting_functions(view:
|
|
12
|
+
def get_charting_functions(view: type) -> dict[str, Callable]:
|
|
12
13
|
"""Discover charting functions."""
|
|
13
14
|
# pylint: disable=import-outside-toplevel
|
|
14
15
|
from inspect import getmembers, getsource, isfunction
|
|
15
16
|
|
|
16
|
-
implemented_functions:
|
|
17
|
+
implemented_functions: dict[str, Callable] = {}
|
|
17
18
|
|
|
18
19
|
for name, obj in getmembers(view, isfunction):
|
|
19
20
|
if (
|
|
@@ -26,7 +27,7 @@ def get_charting_functions(view: Type) -> Dict[str, Callable]:
|
|
|
26
27
|
return implemented_functions
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
def get_charting_functions_list(view:
|
|
30
|
+
def get_charting_functions_list(view: type) -> list[str]:
|
|
30
31
|
"""Get a list of all the charting functions."""
|
|
31
32
|
return list(get_charting_functions(view).keys())
|
|
32
33
|
|
|
@@ -86,9 +87,7 @@ def heikin_ashi(data: "DataFrame") -> "DataFrame":
|
|
|
86
87
|
for item in check_columns:
|
|
87
88
|
if item not in df.columns:
|
|
88
89
|
raise ValueError(
|
|
89
|
-
"The expected column labels, "
|
|
90
|
-
f"{check_columns}"
|
|
91
|
-
", were not found in DataFrame."
|
|
90
|
+
f"The expected column labels, {check_columns}, were not found in DataFrame."
|
|
92
91
|
)
|
|
93
92
|
|
|
94
93
|
ha = candles.ha(
|