openbb-charting 2.2.2__tar.gz → 2.2.4__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.2.2 → openbb_charting-2.2.4}/PKG-INFO +2 -2
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/charting.py +51 -1
- openbb_charting-2.2.4/openbb_charting/charts/correlation_matrix.py +119 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/charts/generic_charts.py +62 -23
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/charts/price_historical.py +23 -7
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/openbb_figure.py +1 -14
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/pyproject.toml +2 -2
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/README.md +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/__init__.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/charts/__init__.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/charts/helpers.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/charts/price_performance.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/charts/relative_rotation.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/__init__.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/assets/Terminal_icon.png +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/assets/plotly-2.32.0.min.js +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/backend.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/chart_style.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/config/__init__.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/config/openbb_styles.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/dummy_backend.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly.html +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/__init__.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/base.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/data_classes.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/plugins/__init__.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/plugins/custom_indicators_plugin.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/plugins/momentum_plugin.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/plugins/overlap_plugin.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/plugins/trend_indicators_plugin.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/plugins/volatility_plugin.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/plugins/volume_plugin.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/ta_class.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/ta_helpers.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/table.html +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/to_chart.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/query_params.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/styles/__init__.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/styles/colors.py +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/styles/default/dark.pltstyle.json +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/styles/default/light.pltstyle.json +0 -0
- {openbb_charting-2.2.2 → openbb_charting-2.2.4}/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.2.
|
|
3
|
+
Version: 2.2.4
|
|
4
4
|
Summary: Charting extension for OpenBB
|
|
5
5
|
License: AGPL-3.0-only
|
|
6
6
|
Author: OpenBB Team
|
|
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
15
15
|
Provides-Extra: pywry
|
|
16
16
|
Requires-Dist: nbformat (>=5.9.2,<6.0.0)
|
|
17
17
|
Requires-Dist: numpy (>=1,<2)
|
|
18
|
-
Requires-Dist: openbb-core (>=1.3.
|
|
18
|
+
Requires-Dist: openbb-core (>=1.3.5,<2.0.0)
|
|
19
19
|
Requires-Dist: pandas-ta (>=0.3.14b,<0.4.0)
|
|
20
20
|
Requires-Dist: plotly (>=5.17.0,<6.0.0)
|
|
21
21
|
Requires-Dist: pywry (>=0.6.1,<0.7.0) ; extra == "pywry"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Charting Class implementation."""
|
|
2
2
|
|
|
3
|
-
# pylint: disable=too-many-arguments,unused-argument
|
|
3
|
+
# pylint: disable=too-many-arguments,unused-argument,too-many-positional-arguments
|
|
4
4
|
|
|
5
5
|
from typing import (
|
|
6
6
|
TYPE_CHECKING,
|
|
@@ -57,6 +57,8 @@ class Charting:
|
|
|
57
57
|
Create a line chart from external data.
|
|
58
58
|
create_bar_chart
|
|
59
59
|
Create a bar chart, on a single x-axis with one or more values for the y-axis, from external data.
|
|
60
|
+
create_correlation_matrix
|
|
61
|
+
Create a correlation matrix from external data.
|
|
60
62
|
toggle_chart_style
|
|
61
63
|
Toggle the chart style, of an existing chart, between light and dark mode.
|
|
62
64
|
"""
|
|
@@ -367,6 +369,54 @@ class Charting:
|
|
|
367
369
|
|
|
368
370
|
return fig
|
|
369
371
|
|
|
372
|
+
def create_correlation_matrix(
|
|
373
|
+
self,
|
|
374
|
+
data: Union[
|
|
375
|
+
list[Data],
|
|
376
|
+
"DataFrame",
|
|
377
|
+
],
|
|
378
|
+
method: Literal["pearson", "kendall", "spearman"] = "pearson",
|
|
379
|
+
colorscale: str = "RdBu",
|
|
380
|
+
title: str = "Asset Correlation Matrix",
|
|
381
|
+
layout_kwargs: Optional[Dict[str, Any]] = None,
|
|
382
|
+
):
|
|
383
|
+
"""Create a correlation matrix from external data.
|
|
384
|
+
|
|
385
|
+
Parameters
|
|
386
|
+
----------
|
|
387
|
+
data : Union[list[Data], DataFrame]
|
|
388
|
+
Input dataset.
|
|
389
|
+
method : Literal["pearson", "kendall", "spearman"]
|
|
390
|
+
Method to use for correlation calculation. Default is "pearson".
|
|
391
|
+
pearson : standard correlation coefficient
|
|
392
|
+
kendall : Kendall Tau correlation coefficient
|
|
393
|
+
spearman : Spearman rank correlation
|
|
394
|
+
colorscale : str
|
|
395
|
+
Plotly colorscale to use for the heatmap. Default is "RdBu".
|
|
396
|
+
title : str
|
|
397
|
+
Title of the chart. Default is "Asset Correlation Matrix".
|
|
398
|
+
layout_kwargs : Dict[str, Any]
|
|
399
|
+
Additional keyword arguments to apply with figure.update_layout(), by default None.
|
|
400
|
+
|
|
401
|
+
Returns
|
|
402
|
+
-------
|
|
403
|
+
OpenBBFigure
|
|
404
|
+
The OpenBBFigure object.
|
|
405
|
+
"""
|
|
406
|
+
# pylint: disable=import-outside-toplevel
|
|
407
|
+
from openbb_charting.charts.correlation_matrix import correlation_matrix
|
|
408
|
+
|
|
409
|
+
kwargs = {
|
|
410
|
+
"data": data,
|
|
411
|
+
"method": method,
|
|
412
|
+
"colorscale": colorscale,
|
|
413
|
+
"title": title,
|
|
414
|
+
"layout_kwargs": layout_kwargs,
|
|
415
|
+
}
|
|
416
|
+
fig, _ = correlation_matrix(**kwargs)
|
|
417
|
+
fig = self._set_chart_style(fig)
|
|
418
|
+
return fig
|
|
419
|
+
|
|
370
420
|
# pylint: disable=inconsistent-return-statements
|
|
371
421
|
def show(self, render: bool = True, **kwargs):
|
|
372
422
|
"""Display chart and save it to the OBBject."""
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Correlation Matrix Chart."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Union
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from plotly.graph_objs import Figure # noqa
|
|
7
|
+
from openbb_charting.core.openbb_figure import OpenBBFigure # noqa
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def correlation_matrix( # noqa: PLR0912
|
|
11
|
+
**kwargs,
|
|
12
|
+
) -> tuple[Union["OpenBBFigure", "Figure"], dict[str, Any]]:
|
|
13
|
+
"""Correlation Matrix Chart."""
|
|
14
|
+
# pylint: disable=import-outside-toplevel
|
|
15
|
+
from numpy import ones_like, triu # noqa
|
|
16
|
+
from openbb_core.app.utils import basemodel_to_df # noqa
|
|
17
|
+
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
18
|
+
from openbb_charting.core.chart_style import ChartStyle
|
|
19
|
+
from plotly.graph_objs import Figure, Heatmap, Layout
|
|
20
|
+
from pandas import DataFrame
|
|
21
|
+
|
|
22
|
+
if "data" in kwargs and isinstance(kwargs["data"], DataFrame):
|
|
23
|
+
corr = kwargs["data"]
|
|
24
|
+
elif "data" in kwargs and isinstance(kwargs["data"], list):
|
|
25
|
+
corr = basemodel_to_df(kwargs["data"], index=kwargs.get("index", "date")) # type: ignore
|
|
26
|
+
else:
|
|
27
|
+
corr = basemodel_to_df(
|
|
28
|
+
kwargs["obbject_item"], index=kwargs.get("index", "date") # type: ignore
|
|
29
|
+
)
|
|
30
|
+
if (
|
|
31
|
+
"symbol" in corr.columns
|
|
32
|
+
and len(corr.symbol.unique()) > 1
|
|
33
|
+
and "close" in corr.columns
|
|
34
|
+
):
|
|
35
|
+
corr = corr.pivot(
|
|
36
|
+
columns="symbol",
|
|
37
|
+
values="close",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
method = kwargs.get("method") or "pearson"
|
|
41
|
+
corr = corr.corr(method=method, numeric_only=True)
|
|
42
|
+
|
|
43
|
+
X = corr.columns.to_list()
|
|
44
|
+
x_replace = X[-1]
|
|
45
|
+
Y = X.copy()
|
|
46
|
+
y_replace = Y[0]
|
|
47
|
+
X = [x if x != x_replace else "" for x in X]
|
|
48
|
+
Y = [y if y != y_replace else "" for y in Y]
|
|
49
|
+
mask = triu(ones_like(corr, dtype=bool))
|
|
50
|
+
df = corr.mask(mask)
|
|
51
|
+
title = kwargs.get("title") or "Asset Correlation Matrix"
|
|
52
|
+
text_color = "white" if ChartStyle().plt_style == "dark" else "black"
|
|
53
|
+
colorscale = kwargs.get("colorscale") or "RdBu"
|
|
54
|
+
|
|
55
|
+
heatmap = Heatmap(
|
|
56
|
+
z=df,
|
|
57
|
+
x=X,
|
|
58
|
+
y=Y,
|
|
59
|
+
xgap=1,
|
|
60
|
+
ygap=1,
|
|
61
|
+
colorscale=colorscale,
|
|
62
|
+
colorbar=dict(
|
|
63
|
+
orientation="v",
|
|
64
|
+
x=0.8,
|
|
65
|
+
y=0.5,
|
|
66
|
+
xanchor="left",
|
|
67
|
+
yanchor="middle",
|
|
68
|
+
xref="container",
|
|
69
|
+
yref="paper",
|
|
70
|
+
len=0.66,
|
|
71
|
+
bgcolor="rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)",
|
|
72
|
+
),
|
|
73
|
+
text=df.fillna(""),
|
|
74
|
+
texttemplate="%{text:.4f}",
|
|
75
|
+
hoverongaps=False,
|
|
76
|
+
hovertemplate="%{x} - %{y} : %{z:.4f}<extra></extra>",
|
|
77
|
+
)
|
|
78
|
+
layout = Layout(
|
|
79
|
+
title=title,
|
|
80
|
+
title_x=0.5,
|
|
81
|
+
xaxis=dict(
|
|
82
|
+
showgrid=False,
|
|
83
|
+
showline=False,
|
|
84
|
+
ticklen=0,
|
|
85
|
+
domain=[0.03, 1],
|
|
86
|
+
tickangle=90,
|
|
87
|
+
automargin=False,
|
|
88
|
+
),
|
|
89
|
+
yaxis=dict(
|
|
90
|
+
showgrid=False,
|
|
91
|
+
side="left",
|
|
92
|
+
autorange="reversed",
|
|
93
|
+
showline=False,
|
|
94
|
+
ticklen=0,
|
|
95
|
+
automargin="height+width+left",
|
|
96
|
+
tickmode="auto",
|
|
97
|
+
),
|
|
98
|
+
margin=dict(l=10, r=0, t=0, b=10),
|
|
99
|
+
dragmode="pan",
|
|
100
|
+
)
|
|
101
|
+
fig = Figure(data=[heatmap], layout=layout)
|
|
102
|
+
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
|
+
layout_kwargs = kwargs.get("layout_kwargs", {})
|
|
113
|
+
|
|
114
|
+
if layout_kwargs:
|
|
115
|
+
figure.update_layout(**layout_kwargs)
|
|
116
|
+
|
|
117
|
+
content = figure.show(external=True).to_plotly_json() # type: ignore
|
|
118
|
+
|
|
119
|
+
return figure, content
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Generic Charts Module."""
|
|
2
2
|
|
|
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
|
|
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
5
|
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union
|
|
6
6
|
|
|
@@ -52,7 +52,7 @@ def line_chart( # noqa: PLR0912
|
|
|
52
52
|
"""Create a line chart."""
|
|
53
53
|
# pylint: disable=import-outside-toplevel
|
|
54
54
|
from pandas import DataFrame, Series, to_datetime # noqa
|
|
55
|
-
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
55
|
+
from openbb_charting.core.openbb_figure import OpenBBFigure
|
|
56
56
|
|
|
57
57
|
if data is None:
|
|
58
58
|
raise ValueError("Error: Data is a required field.")
|
|
@@ -122,6 +122,8 @@ def line_chart( # noqa: PLR0912
|
|
|
122
122
|
except Exception as _:
|
|
123
123
|
fig = OpenBBFigure(create_backend=True)
|
|
124
124
|
|
|
125
|
+
fig.update_layout(ChartStyle().plotly_template.get("layout", {}))
|
|
126
|
+
text_color = "white" if ChartStyle().plt_style == "dark" else "black"
|
|
125
127
|
title = f"{title}" if title else ""
|
|
126
128
|
xtitle = xtitle if xtitle else ""
|
|
127
129
|
y1title = ytitle if ytitle else ""
|
|
@@ -242,15 +244,24 @@ def line_chart( # noqa: PLR0912
|
|
|
242
244
|
|
|
243
245
|
fig.update_layout(
|
|
244
246
|
title=dict(text=title if title else None, x=0.5, font=dict(size=16)),
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
font=dict(color=text_color),
|
|
248
|
+
paper_bgcolor=(
|
|
249
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
250
|
+
),
|
|
251
|
+
plot_bgcolor=(
|
|
252
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
253
|
+
),
|
|
247
254
|
legend=dict(
|
|
248
|
-
orientation="
|
|
249
|
-
yanchor="
|
|
255
|
+
orientation="v",
|
|
256
|
+
yanchor="top",
|
|
250
257
|
xanchor="right",
|
|
251
|
-
y=
|
|
252
|
-
x
|
|
253
|
-
|
|
258
|
+
y=0.95,
|
|
259
|
+
x=-0.01,
|
|
260
|
+
xref="paper",
|
|
261
|
+
font=dict(size=12),
|
|
262
|
+
bgcolor=(
|
|
263
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
264
|
+
),
|
|
254
265
|
),
|
|
255
266
|
yaxis=(
|
|
256
267
|
dict(
|
|
@@ -405,6 +416,7 @@ def bar_chart( # noqa: PLR0912
|
|
|
405
416
|
)
|
|
406
417
|
|
|
407
418
|
figure.update_layout(ChartStyle().plotly_template.get("layout", {}))
|
|
419
|
+
text_color = "white" if ChartStyle().plt_style == "dark" else "black"
|
|
408
420
|
if colors is not None:
|
|
409
421
|
figure.update_layout(colorway=colors)
|
|
410
422
|
if bar_kwargs is None:
|
|
@@ -414,7 +426,8 @@ def bar_chart( # noqa: PLR0912
|
|
|
414
426
|
|
|
415
427
|
bar_df = data.copy().set_index(x) # type: ignore
|
|
416
428
|
y = y.split(",") if isinstance(y, str) else y
|
|
417
|
-
|
|
429
|
+
hovertemplate = bar_kwargs.pop("hovertemplate", None)
|
|
430
|
+
width = bar_kwargs.pop("width", None)
|
|
418
431
|
for item in y:
|
|
419
432
|
figure.add_bar(
|
|
420
433
|
x=bar_df.index if orientation == "v" else bar_df[item],
|
|
@@ -424,25 +437,41 @@ def bar_chart( # noqa: PLR0912
|
|
|
424
437
|
legendgroup=bar_df[item].name,
|
|
425
438
|
orientation=orientation,
|
|
426
439
|
hovertemplate=(
|
|
427
|
-
|
|
428
|
-
if
|
|
429
|
-
else
|
|
440
|
+
hovertemplate
|
|
441
|
+
if hovertemplate
|
|
442
|
+
else (
|
|
443
|
+
"%{fullData.name}:%{y}<extra></extra>"
|
|
444
|
+
if orientation == "v"
|
|
445
|
+
else "%{fullData.name}:%{x}<extra></extra>"
|
|
446
|
+
)
|
|
447
|
+
),
|
|
448
|
+
width=(
|
|
449
|
+
width
|
|
450
|
+
if width
|
|
451
|
+
else 0.95 / len(y) * 0.75 if barmode == "group" and len(y) > 1 else 0.95
|
|
430
452
|
),
|
|
431
|
-
width=0.95 / len(y) * 0.75 if barmode == "group" and len(y) > 1 else 0.95,
|
|
432
453
|
**bar_kwargs,
|
|
433
454
|
)
|
|
434
455
|
|
|
435
456
|
figure.update_layout(
|
|
436
457
|
title=dict(text=title if title else None, x=0.5, font=dict(size=16)),
|
|
437
|
-
paper_bgcolor=
|
|
438
|
-
|
|
458
|
+
paper_bgcolor=(
|
|
459
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
460
|
+
),
|
|
461
|
+
plot_bgcolor=(
|
|
462
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rbga(255,255,255,0)"
|
|
463
|
+
),
|
|
439
464
|
legend=dict(
|
|
440
|
-
orientation="
|
|
441
|
-
yanchor="
|
|
465
|
+
orientation="v",
|
|
466
|
+
yanchor="top",
|
|
442
467
|
xanchor="right",
|
|
443
|
-
y=
|
|
444
|
-
x
|
|
445
|
-
|
|
468
|
+
y=0.95,
|
|
469
|
+
x=-0.01 if orientation == "v" else 1.01,
|
|
470
|
+
xref="paper",
|
|
471
|
+
font=dict(size=12),
|
|
472
|
+
bgcolor=(
|
|
473
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
474
|
+
),
|
|
446
475
|
),
|
|
447
476
|
xaxis=dict(
|
|
448
477
|
type=xtype,
|
|
@@ -469,6 +498,7 @@ def bar_chart( # noqa: PLR0912
|
|
|
469
498
|
),
|
|
470
499
|
margin=dict(pad=5),
|
|
471
500
|
barmode=barmode,
|
|
501
|
+
font=dict(color=text_color),
|
|
472
502
|
)
|
|
473
503
|
if orientation == "h":
|
|
474
504
|
figure.update_layout(
|
|
@@ -483,6 +513,7 @@ def bar_chart( # noqa: PLR0912
|
|
|
483
513
|
hoverlabel=dict(
|
|
484
514
|
font=dict(size=12),
|
|
485
515
|
),
|
|
516
|
+
hovermode="y unified",
|
|
486
517
|
)
|
|
487
518
|
if layout_kwargs:
|
|
488
519
|
figure.update_layout(
|
|
@@ -532,7 +563,7 @@ def bar_increasing_decreasing( # pylint: disable=W0102
|
|
|
532
563
|
"""
|
|
533
564
|
# pylint: disable=import-outside-toplevel
|
|
534
565
|
from openbb_charting.core.openbb_figure import OpenBBFigure # noqa
|
|
535
|
-
from pandas import Series
|
|
566
|
+
from pandas import Series
|
|
536
567
|
|
|
537
568
|
try:
|
|
538
569
|
figure = OpenBBFigure()
|
|
@@ -548,7 +579,8 @@ def bar_increasing_decreasing( # pylint: disable=W0102
|
|
|
548
579
|
row_width=[1],
|
|
549
580
|
specs=[[{"secondary_y": True}]],
|
|
550
581
|
)
|
|
551
|
-
|
|
582
|
+
figure.update_layout(ChartStyle().plotly_template.get("layout", {}))
|
|
583
|
+
text_color = "white" if ChartStyle().plt_style == "dark" else "black"
|
|
552
584
|
|
|
553
585
|
try:
|
|
554
586
|
data = Series(data=values, index=keys)
|
|
@@ -605,6 +637,13 @@ def bar_increasing_decreasing( # pylint: disable=W0102
|
|
|
605
637
|
categoryorder="array" if orientation == "v" else None,
|
|
606
638
|
categoryarray=keys if orientation == "v" else None,
|
|
607
639
|
),
|
|
640
|
+
paper_bgcolor=(
|
|
641
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
642
|
+
),
|
|
643
|
+
plot_bgcolor=(
|
|
644
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
645
|
+
),
|
|
646
|
+
font=dict(color="white" if text_color == "white" else "black"),
|
|
608
647
|
margin=dict(pad=5),
|
|
609
648
|
)
|
|
610
649
|
|
|
@@ -120,8 +120,12 @@ def price_historical( # noqa: PLR0912
|
|
|
120
120
|
if _volume is True and "atr" in indicators: # type: ignore
|
|
121
121
|
fig.add_inchart_volume(data)
|
|
122
122
|
fig.update_layout(
|
|
123
|
-
paper_bgcolor=
|
|
124
|
-
|
|
123
|
+
paper_bgcolor=(
|
|
124
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
125
|
+
),
|
|
126
|
+
plot_bgcolor=(
|
|
127
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
128
|
+
),
|
|
125
129
|
font=dict(color=text_color),
|
|
126
130
|
showlegend=True,
|
|
127
131
|
legend=dict(
|
|
@@ -132,7 +136,9 @@ def price_historical( # noqa: PLR0912
|
|
|
132
136
|
x=-0.01,
|
|
133
137
|
xref="paper",
|
|
134
138
|
font=dict(size=12),
|
|
135
|
-
bgcolor=
|
|
139
|
+
bgcolor=(
|
|
140
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
141
|
+
),
|
|
136
142
|
),
|
|
137
143
|
xaxis=dict(
|
|
138
144
|
ticklen=0,
|
|
@@ -207,6 +213,8 @@ def price_historical( # noqa: PLR0912
|
|
|
207
213
|
y2title = None # type: ignore
|
|
208
214
|
|
|
209
215
|
fig = OpenBBFigure()
|
|
216
|
+
fig.update_layout(ChartStyle().plotly_template.get("layout", {}))
|
|
217
|
+
text_color = "white" if ChartStyle().plt_style == "dark" else "black"
|
|
210
218
|
|
|
211
219
|
for i, col in enumerate(data.columns):
|
|
212
220
|
|
|
@@ -248,8 +256,12 @@ def price_historical( # noqa: PLR0912
|
|
|
248
256
|
y2title = None # type: ignore
|
|
249
257
|
|
|
250
258
|
fig.update_layout(
|
|
251
|
-
paper_bgcolor=
|
|
252
|
-
|
|
259
|
+
paper_bgcolor=(
|
|
260
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
261
|
+
),
|
|
262
|
+
plot_bgcolor=(
|
|
263
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
264
|
+
),
|
|
253
265
|
legend=(
|
|
254
266
|
dict(
|
|
255
267
|
orientation="v",
|
|
@@ -257,7 +269,9 @@ def price_historical( # noqa: PLR0912
|
|
|
257
269
|
xanchor="right",
|
|
258
270
|
y=0.95,
|
|
259
271
|
x=-0.01,
|
|
260
|
-
bgcolor=
|
|
272
|
+
bgcolor=(
|
|
273
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
274
|
+
),
|
|
261
275
|
)
|
|
262
276
|
if len(data.columns) > 2
|
|
263
277
|
else dict(
|
|
@@ -266,7 +280,9 @@ def price_historical( # noqa: PLR0912
|
|
|
266
280
|
xanchor="right",
|
|
267
281
|
y=1.02,
|
|
268
282
|
x=0.98,
|
|
269
|
-
bgcolor=
|
|
283
|
+
bgcolor=(
|
|
284
|
+
"rgba(0,0,0,0)" if text_color == "white" else "rgba(255,255,255,0)"
|
|
285
|
+
),
|
|
270
286
|
)
|
|
271
287
|
),
|
|
272
288
|
yaxis1=(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""OpenBB Figure Class."""
|
|
2
2
|
|
|
3
|
-
# pylint: disable=C0302,R0902,W3301
|
|
3
|
+
# pylint: disable=C0302,R0902,W3301,R0917
|
|
4
4
|
import json
|
|
5
5
|
import textwrap
|
|
6
6
|
from datetime import datetime, timedelta
|
|
@@ -925,19 +925,6 @@ class OpenBBFigure(go.Figure):
|
|
|
925
925
|
if data.get("layout", {}):
|
|
926
926
|
pio.show(data, *args, **kwargs)
|
|
927
927
|
|
|
928
|
-
self.update_layout(
|
|
929
|
-
legend=dict(
|
|
930
|
-
orientation=(
|
|
931
|
-
"v"
|
|
932
|
-
if not self.layout.legend.orientation
|
|
933
|
-
else self.layout.legend.orientation
|
|
934
|
-
),
|
|
935
|
-
),
|
|
936
|
-
barmode="overlay",
|
|
937
|
-
bargap=0,
|
|
938
|
-
bargroupgap=0,
|
|
939
|
-
)
|
|
940
|
-
|
|
941
928
|
return pio.show(self, *args, **kwargs)
|
|
942
929
|
|
|
943
930
|
def _xaxis_tickformatstops(self) -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "openbb-charting"
|
|
3
|
-
version = "2.2.
|
|
3
|
+
version = "2.2.4"
|
|
4
4
|
description = "Charting extension for OpenBB"
|
|
5
5
|
authors = ["OpenBB Team <hello@openbb.co>"]
|
|
6
6
|
license = "AGPL-3.0-only"
|
|
@@ -15,7 +15,7 @@ statsmodels = "^0.14.0"
|
|
|
15
15
|
pywry = { version = "^0.6.1", optional = true }
|
|
16
16
|
nbformat = "^5.9.2"
|
|
17
17
|
pandas-ta = "^0.3.14b"
|
|
18
|
-
openbb-core = "^1.3.
|
|
18
|
+
openbb-core = "^1.3.5"
|
|
19
19
|
numpy = "^1"
|
|
20
20
|
|
|
21
21
|
[tool.poetry.extras]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/assets/Terminal_icon.png
RENAMED
|
File without changes
|
{openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/assets/plotly-2.32.0.min.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/config/openbb_styles.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/core/plotly_ta/data_classes.py
RENAMED
|
File without changes
|
{openbb_charting-2.2.2 → openbb_charting-2.2.4}/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.2.2 → openbb_charting-2.2.4}/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.2.2 → openbb_charting-2.2.4}/openbb_charting/styles/default/dark.pltstyle.json
RENAMED
|
File without changes
|
{openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/styles/default/light.pltstyle.json
RENAMED
|
File without changes
|
{openbb_charting-2.2.2 → openbb_charting-2.2.4}/openbb_charting/styles/default/tables.pltstyle.json
RENAMED
|
File without changes
|