openbb-charting 2.0.3__tar.gz → 2.1.0__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.0.3 → openbb_charting-2.1.0}/PKG-INFO +4 -2
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/__init__.py +50 -22
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/backend.py +7 -2
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/pyproject.toml +3 -2
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/README.md +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/builder.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/charting_router.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/__init__.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/assets/Terminal_icon.png +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/assets/plotly-2.24.2.min.js +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/chart_style.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/config/__init__.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/config/openbb_styles.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/dummy_backend.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/openbb_figure.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly.html +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/__init__.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/base.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/data_classes.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/plugins/__init__.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/plugins/custom_indicators_plugin.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/plugins/momentum_plugin.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/plugins/overlap_plugin.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/plugins/trend_indicators_plugin.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/plugins/volatility_plugin.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/plugins/volume_plugin.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/ta_class.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/ta_helpers.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/table.html +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/to_chart.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/query_params.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/styles/__init__.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/styles/colors.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/styles/default/dark.pltstyle.json +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/styles/default/light.pltstyle.json +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/styles/default/tables.pltstyle.json +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/utils/__init__.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/utils/generic_charts.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/utils/helpers.py +0 -0
- {openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/utils/relative_rotation.py +0 -0
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: openbb-charting
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Charting extension for OpenBB
|
|
5
|
+
License: AGPL-3.0-only
|
|
5
6
|
Author: OpenBB Team
|
|
6
7
|
Author-email: hello@openbb.co
|
|
7
8
|
Requires-Python: >=3.8,<3.12
|
|
9
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
8
10
|
Classifier: Programming Language :: Python :: 3
|
|
9
11
|
Classifier: Programming Language :: Python :: 3.8
|
|
10
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
11
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
15
|
Requires-Dist: nbformat (>=5.9.2,<6.0.0)
|
|
14
|
-
Requires-Dist: openbb-core (>=1.1
|
|
16
|
+
Requires-Dist: openbb-core (>=1.2.1,<2.0.0)
|
|
15
17
|
Requires-Dist: pandas-ta (>=0.3.14b,<0.4.0)
|
|
16
18
|
Requires-Dist: plotly (>=5.17.0,<6.0.0)
|
|
17
19
|
Requires-Dist: pywry (>=0.6.1,<0.7.0)
|
|
@@ -35,13 +35,12 @@ warnings.filterwarnings(
|
|
|
35
35
|
"ignore", category=UserWarning, module="openbb_core.app.model.extension", lineno=47
|
|
36
36
|
)
|
|
37
37
|
|
|
38
|
-
ext = Extension(name="charting")
|
|
38
|
+
ext = Extension(name="charting", description="Create custom charts from OBBject data.")
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
@ext.obbject_accessor
|
|
42
42
|
class Charting:
|
|
43
|
-
"""
|
|
44
|
-
Charting extension.
|
|
43
|
+
"""Charting extension.
|
|
45
44
|
|
|
46
45
|
Methods
|
|
47
46
|
-------
|
|
@@ -61,6 +60,8 @@ class Charting:
|
|
|
61
60
|
Create a line chart from external data.
|
|
62
61
|
create_bar_chart
|
|
63
62
|
Create a bar chart, on a single x-axis with one or more values for the y-axis, from external data.
|
|
63
|
+
toggle_chart_style
|
|
64
|
+
Toggle the chart style, of an existing chart, between light and dark mode.
|
|
64
65
|
"""
|
|
65
66
|
|
|
66
67
|
def __init__(self, obbject):
|
|
@@ -77,8 +78,8 @@ class Charting:
|
|
|
77
78
|
|
|
78
79
|
@classmethod
|
|
79
80
|
def indicators(cls):
|
|
80
|
-
"""
|
|
81
|
-
|
|
81
|
+
"""Return an instance of the IndicatorsParams class, containing all available indicators and their parameters.
|
|
82
|
+
|
|
82
83
|
Without assigning to a variable, it will print the the information to the console.
|
|
83
84
|
"""
|
|
84
85
|
return IndicatorsParams()
|
|
@@ -90,7 +91,6 @@ class Charting:
|
|
|
90
91
|
|
|
91
92
|
def _handle_backend(self) -> Backend:
|
|
92
93
|
"""Create and start the backend."""
|
|
93
|
-
|
|
94
94
|
create_backend(self._charting_settings)
|
|
95
95
|
backend = get_backend()
|
|
96
96
|
backend.start(debug=self._charting_settings.debug_mode)
|
|
@@ -99,15 +99,14 @@ class Charting:
|
|
|
99
99
|
@staticmethod
|
|
100
100
|
def _get_chart_function(route: str) -> Callable:
|
|
101
101
|
"""Given a route, it returns the chart function. The module must contain the given route."""
|
|
102
|
-
|
|
103
102
|
if route is None:
|
|
104
103
|
raise ValueError("OBBject was initialized with no function route.")
|
|
105
104
|
adjusted_route = route.replace("/", "_")[1:]
|
|
106
105
|
return getattr(charting_router, adjusted_route)
|
|
107
106
|
|
|
108
107
|
def get_params(self) -> ChartParams:
|
|
109
|
-
"""
|
|
110
|
-
|
|
108
|
+
"""Return the ChartQueryParams class for the function the OBBject was created from.
|
|
109
|
+
|
|
111
110
|
Without assigning to a variable, it will print the docstring to the console.
|
|
112
111
|
"""
|
|
113
112
|
if self._obbject._route is None: # pylint: disable=protected-access
|
|
@@ -126,7 +125,7 @@ class Charting:
|
|
|
126
125
|
) -> Tuple[pd.DataFrame, bool]:
|
|
127
126
|
"""Convert supplied data to a DataFrame."""
|
|
128
127
|
has_data = (
|
|
129
|
-
isinstance(data, (Data, pd.DataFrame, pd.Series)) and not data.empty
|
|
128
|
+
isinstance(data, (Data, pd.DataFrame, pd.Series)) and not data.empty # type: ignore
|
|
130
129
|
) or (bool(data))
|
|
131
130
|
index = (
|
|
132
131
|
data.index.name
|
|
@@ -234,6 +233,7 @@ class Charting:
|
|
|
234
233
|
same_axis=same_axis,
|
|
235
234
|
**kwargs,
|
|
236
235
|
)
|
|
236
|
+
fig = self._set_chart_style(fig)
|
|
237
237
|
if render:
|
|
238
238
|
return fig.show(**kwargs)
|
|
239
239
|
|
|
@@ -298,7 +298,6 @@ class Charting:
|
|
|
298
298
|
OpenBBFigure
|
|
299
299
|
The OpenBBFigure object.
|
|
300
300
|
"""
|
|
301
|
-
|
|
302
301
|
fig = bar_chart(
|
|
303
302
|
data=data,
|
|
304
303
|
x=x,
|
|
@@ -313,7 +312,7 @@ class Charting:
|
|
|
313
312
|
bar_kwargs=bar_kwargs,
|
|
314
313
|
layout_kwargs=layout_kwargs,
|
|
315
314
|
)
|
|
316
|
-
|
|
315
|
+
fig = self._set_chart_style(fig)
|
|
317
316
|
if render:
|
|
318
317
|
return fig.show(**kwargs)
|
|
319
318
|
|
|
@@ -322,7 +321,6 @@ class Charting:
|
|
|
322
321
|
# pylint: disable=inconsistent-return-statements
|
|
323
322
|
def show(self, render: bool = True, **kwargs):
|
|
324
323
|
"""Display chart and save it to the OBBject."""
|
|
325
|
-
|
|
326
324
|
try:
|
|
327
325
|
charting_function = self._get_chart_function(
|
|
328
326
|
self._obbject._route # pylint: disable=protected-access
|
|
@@ -345,14 +343,17 @@ class Charting:
|
|
|
345
343
|
_kwargs = kwargs.pop("kwargs")
|
|
346
344
|
kwargs.update(_kwargs.get("chart_params", {}))
|
|
347
345
|
fig, content = charting_function(**kwargs)
|
|
346
|
+
fig = self._set_chart_style(fig)
|
|
347
|
+
content = fig.show(external=True, **kwargs).to_plotly_json()
|
|
348
348
|
self._obbject.chart = Chart(
|
|
349
349
|
fig=fig, content=content, format=charting_router.CHART_FORMAT
|
|
350
350
|
)
|
|
351
351
|
if render:
|
|
352
352
|
fig.show(**kwargs)
|
|
353
|
-
except Exception:
|
|
353
|
+
except Exception: # pylint: disable=W0718
|
|
354
354
|
try:
|
|
355
355
|
fig = self.create_line_chart(data=self._obbject.results, render=False, **kwargs) # type: ignore
|
|
356
|
+
fig = self._set_chart_style(fig)
|
|
356
357
|
content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
|
|
357
358
|
self._obbject.chart = Chart(
|
|
358
359
|
fig=fig, content=content, format=charting_router.CHART_FORMAT
|
|
@@ -389,11 +390,10 @@ class Charting:
|
|
|
389
390
|
render: bool = True,
|
|
390
391
|
**kwargs,
|
|
391
392
|
):
|
|
392
|
-
"""
|
|
393
|
-
|
|
393
|
+
"""Create an OpenBBFigure with user customizations (if any) and save it to the OBBject.
|
|
394
|
+
|
|
394
395
|
This function is used to populate, or re-populate, the OBBject with a chart using the data within
|
|
395
396
|
the OBBject or external data supplied via the `data` parameter.
|
|
396
|
-
|
|
397
397
|
This function modifies the original OBBject by overwriting the existing chart.
|
|
398
398
|
|
|
399
399
|
Parameters
|
|
@@ -467,27 +467,55 @@ class Charting:
|
|
|
467
467
|
self.show(data=data_as_df, render=render, **kwargs)
|
|
468
468
|
else:
|
|
469
469
|
self.show(**kwargs, render=render)
|
|
470
|
-
except Exception:
|
|
470
|
+
except Exception: # pylint: disable=W0718
|
|
471
471
|
try:
|
|
472
472
|
fig = self.create_line_chart(data=data_as_df, render=False, **kwargs)
|
|
473
|
+
fig = self._set_chart_style(fig)
|
|
473
474
|
content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
|
|
474
475
|
self._obbject.chart = Chart(
|
|
475
476
|
fig=fig, content=content, format=charting_router.CHART_FORMAT
|
|
476
477
|
)
|
|
477
478
|
if render:
|
|
478
479
|
return fig.show(**kwargs) # type: ignore
|
|
479
|
-
except Exception as e:
|
|
480
|
+
except Exception as e: # pylint: disable=W0718
|
|
480
481
|
raise RuntimeError(
|
|
481
482
|
"Failed to automatically create a generic chart with the data provided."
|
|
482
483
|
) from e
|
|
483
484
|
|
|
485
|
+
def _set_chart_style(self, figure: Figure):
|
|
486
|
+
"""Set the user preference for light or dark mode."""
|
|
487
|
+
style = self._charting_settings.chart_style # pylint: disable=protected-access
|
|
488
|
+
font_color = "black" if style == "light" else "white"
|
|
489
|
+
paper_bgcolor = "white" if style == "light" else "black"
|
|
490
|
+
figure = figure.update_layout(
|
|
491
|
+
dict( # pylint: disable=R1735
|
|
492
|
+
font_color=font_color, paper_bgcolor=paper_bgcolor
|
|
493
|
+
)
|
|
494
|
+
)
|
|
495
|
+
return figure
|
|
496
|
+
|
|
497
|
+
def toggle_chart_style(self): # pylint: disable=protected-access
|
|
498
|
+
"""Toggle the chart style between light and dark mode."""
|
|
499
|
+
if not hasattr(self._obbject.chart, "fig"):
|
|
500
|
+
raise ValueError(
|
|
501
|
+
"Error: No chart has been created. Please create a chart first."
|
|
502
|
+
)
|
|
503
|
+
current = self._charting_settings.chart_style
|
|
504
|
+
new = "light" if current == "dark" else "dark"
|
|
505
|
+
self._charting_settings.chart_style = new
|
|
506
|
+
figure = self._obbject.chart.fig # type: ignore[union-attr]
|
|
507
|
+
updated_figure = self._set_chart_style(figure)
|
|
508
|
+
self._obbject.chart.fig = updated_figure # type: ignore[union-attr]
|
|
509
|
+
self._obbject.chart.content = updated_figure.show( # type: ignore[union-attr]
|
|
510
|
+
external=True
|
|
511
|
+
).to_plotly_json()
|
|
512
|
+
|
|
484
513
|
def table(
|
|
485
514
|
self,
|
|
486
515
|
data: Optional[Union[pd.DataFrame, pd.Series]] = None,
|
|
487
516
|
title: str = "",
|
|
488
517
|
):
|
|
489
|
-
"""
|
|
490
|
-
Display an interactive table.
|
|
518
|
+
"""Display an interactive table.
|
|
491
519
|
|
|
492
520
|
Parameters
|
|
493
521
|
----------
|
|
@@ -510,7 +538,7 @@ class Charting:
|
|
|
510
538
|
or self._obbject._route, # pylint: disable=protected-access
|
|
511
539
|
theme=self._charting_settings.table_style,
|
|
512
540
|
)
|
|
513
|
-
except Exception as e:
|
|
541
|
+
except Exception as e: # pylint: disable=W0718
|
|
514
542
|
warn(f"Failed to show figure with backend. {e}")
|
|
515
543
|
|
|
516
544
|
else:
|
|
@@ -198,6 +198,12 @@ class Backend(PyWry):
|
|
|
198
198
|
self.check_backend()
|
|
199
199
|
# pylint: disable=C0415
|
|
200
200
|
|
|
201
|
+
paper_bg = (
|
|
202
|
+
"rgba(0,0,0,0)"
|
|
203
|
+
if self.charting_settings.chart_style == "dark"
|
|
204
|
+
else "rgba(255,255,255,0)"
|
|
205
|
+
)
|
|
206
|
+
|
|
201
207
|
title = "Interactive Chart"
|
|
202
208
|
|
|
203
209
|
fig.layout.title.text = re.sub(
|
|
@@ -210,9 +216,8 @@ class Backend(PyWry):
|
|
|
210
216
|
export_image = Path(export_image).resolve()
|
|
211
217
|
|
|
212
218
|
json_data = json.loads(fig.to_json())
|
|
213
|
-
|
|
214
219
|
json_data.update(self.get_json_update(command_location))
|
|
215
|
-
|
|
220
|
+
json_data["layout"]["paper_bgcolor"] = paper_bg
|
|
216
221
|
outgoing = dict(
|
|
217
222
|
html=self.get_plotly_html(),
|
|
218
223
|
json_data=json_data,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "openbb-charting"
|
|
3
|
-
version = "2.0
|
|
3
|
+
version = "2.1.0"
|
|
4
4
|
description = "Charting extension for OpenBB"
|
|
5
5
|
authors = ["OpenBB Team <hello@openbb.co>"]
|
|
6
|
+
license = "AGPL-3.0-only"
|
|
6
7
|
readme = "README.md"
|
|
7
8
|
packages = [{ include = "openbb_charting" }]
|
|
8
9
|
|
|
@@ -16,7 +17,7 @@ pywry = "^0.6.1"
|
|
|
16
17
|
svglib = "^1.5.1"
|
|
17
18
|
nbformat = "^5.9.2"
|
|
18
19
|
pandas-ta = "^0.3.14b"
|
|
19
|
-
openbb-core = "^1.1
|
|
20
|
+
openbb-core = "^1.2.1"
|
|
20
21
|
|
|
21
22
|
[build-system]
|
|
22
23
|
requires = ["poetry-core"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/assets/Terminal_icon.png
RENAMED
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/assets/plotly-2.24.2.min.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/config/openbb_styles.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/data_classes.py
RENAMED
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/plugins/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/core/plotly_ta/ta_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/styles/default/dark.pltstyle.json
RENAMED
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/styles/default/light.pltstyle.json
RENAMED
|
File without changes
|
{openbb_charting-2.0.3 → openbb_charting-2.1.0}/openbb_charting/styles/default/tables.pltstyle.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|