openbb-charting 2.2.0__tar.gz → 2.2.2__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.
Files changed (41) hide show
  1. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/PKG-INFO +4 -3
  2. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/charting.py +28 -0
  3. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/backend.py +6 -17
  4. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/dummy_backend.py +0 -25
  5. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/pyproject.toml +6 -3
  6. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/README.md +0 -0
  7. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/__init__.py +0 -0
  8. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/charts/__init__.py +0 -0
  9. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/charts/generic_charts.py +0 -0
  10. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/charts/helpers.py +0 -0
  11. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/charts/price_historical.py +0 -0
  12. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/charts/price_performance.py +0 -0
  13. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/charts/relative_rotation.py +0 -0
  14. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/__init__.py +0 -0
  15. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/assets/Terminal_icon.png +0 -0
  16. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/assets/plotly-2.32.0.min.js +0 -0
  17. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/chart_style.py +0 -0
  18. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/config/__init__.py +0 -0
  19. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/config/openbb_styles.py +0 -0
  20. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/openbb_figure.py +0 -0
  21. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly.html +0 -0
  22. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/__init__.py +0 -0
  23. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/base.py +0 -0
  24. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/data_classes.py +0 -0
  25. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/plugins/__init__.py +0 -0
  26. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/plugins/custom_indicators_plugin.py +0 -0
  27. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/plugins/momentum_plugin.py +0 -0
  28. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/plugins/overlap_plugin.py +0 -0
  29. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/plugins/trend_indicators_plugin.py +0 -0
  30. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/plugins/volatility_plugin.py +0 -0
  31. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/plugins/volume_plugin.py +0 -0
  32. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/ta_class.py +0 -0
  33. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/plotly_ta/ta_helpers.py +0 -0
  34. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/table.html +0 -0
  35. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/core/to_chart.py +0 -0
  36. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/query_params.py +0 -0
  37. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/styles/__init__.py +0 -0
  38. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/styles/colors.py +0 -0
  39. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/styles/default/dark.pltstyle.json +0 -0
  40. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/openbb_charting/styles/default/light.pltstyle.json +0 -0
  41. {openbb_charting-2.2.0 → openbb_charting-2.2.2}/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.0
3
+ Version: 2.2.2
4
4
  Summary: Charting extension for OpenBB
5
5
  License: AGPL-3.0-only
6
6
  Author: OpenBB Team
@@ -12,12 +12,13 @@ Classifier: Programming Language :: Python :: 3.9
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
+ Provides-Extra: pywry
15
16
  Requires-Dist: nbformat (>=5.9.2,<6.0.0)
16
17
  Requires-Dist: numpy (>=1,<2)
17
- Requires-Dist: openbb-core (>=1.3.0,<2.0.0)
18
+ Requires-Dist: openbb-core (>=1.3.2,<2.0.0)
18
19
  Requires-Dist: pandas-ta (>=0.3.14b,<0.4.0)
19
20
  Requires-Dist: plotly (>=5.17.0,<6.0.0)
20
- Requires-Dist: pywry (>=0.6.1,<0.7.0)
21
+ Requires-Dist: pywry (>=0.6.1,<0.7.0) ; extra == "pywry"
21
22
  Requires-Dist: scipy (>=1.10.0,<2.0.0)
22
23
  Requires-Dist: statsmodels (>=0.14.0,<0.15.0)
23
24
  Description-Content-Type: text/markdown
@@ -546,6 +546,32 @@ class Charting:
546
546
  external=True
547
547
  ).to_plotly_json()
548
548
 
549
+ @staticmethod
550
+ def _convert_to_string(x):
551
+ """Sanitize the data for the table."""
552
+ # pylint: disable=import-outside-toplevel
553
+ from numpy import isnan
554
+
555
+ if isinstance(x, (float, int)) and not isnan(x):
556
+ return x
557
+ if isinstance(x, dict):
558
+ return ", ".join([str(v) for v in x.values()])
559
+ if isinstance(x, list):
560
+ if all(isinstance(i, dict) for i in x):
561
+ return ", ".join(
562
+ str(", ".join([str(v) for v in i.values()])) for i in x
563
+ )
564
+ return ", ".join([str(i) for i in x])
565
+
566
+ return (
567
+ str(x)
568
+ .replace("[", "")
569
+ .replace("]", "")
570
+ .replace("'{", "")
571
+ .replace("}'", "")
572
+ .replace("nan", "")
573
+ )
574
+
549
575
  def table(
550
576
  self,
551
577
  data: Optional[Union["DataFrame", "Series"]] = None,
@@ -569,6 +595,8 @@ class Charting:
569
595
  data_as_df.reset_index(inplace=True, drop=True)
570
596
  else:
571
597
  data_as_df.reset_index(inplace=True)
598
+ for col in data_as_df.columns:
599
+ data_as_df[col] = data_as_df[col].apply(self._convert_to_string)
572
600
  if self._backend.isatty:
573
601
  try:
574
602
  self._backend.send_table(
@@ -3,8 +3,6 @@
3
3
  from pathlib import Path
4
4
  from typing import TYPE_CHECKING, Any, Dict, Optional, Union
5
5
 
6
- from openbb_core.env import Env
7
-
8
6
  if TYPE_CHECKING:
9
7
  from openbb_core.app.model.charts.charting_settings import ChartingSettings
10
8
  from pandas import DataFrame
@@ -16,9 +14,7 @@ BACKEND = None
16
14
 
17
15
  try:
18
16
  from pywry import PyWry # pylint: disable=import-outside-toplevel
19
- except ImportError as e:
20
- if Env().DEBUG_MODE:
21
- print(f"\033[91m{e}\033[0m") # noqa: T201
17
+ except ImportError:
22
18
  from .dummy_backend import DummyBackend # pylint: disable=import-outside-toplevel
23
19
 
24
20
  class PyWry(DummyBackend): # type: ignore
@@ -89,8 +85,8 @@ class Backend(PyWry):
89
85
 
90
86
  def set_window_dimensions(self):
91
87
  """Set the window dimensions."""
92
- width = self.charting_settings.plot_pywry_width or 1400
93
- height = self.charting_settings.plot_pywry_height or 762
88
+ width = 1400
89
+ height = 762
94
90
 
95
91
  self.WIDTH, self.HEIGHT = int(width), int(height)
96
92
 
@@ -233,7 +229,6 @@ class Backend(PyWry):
233
229
  """Check if the image has been exported to the path."""
234
230
  # pylint: disable=import-outside-toplevel
235
231
  import asyncio
236
- import os
237
232
  import subprocess
238
233
  import sys
239
234
 
@@ -247,14 +242,8 @@ class Backend(PyWry):
247
242
  break
248
243
 
249
244
  if img_path.exists(): # noqa: SIM102
250
- if self.charting_settings.plot_open_export:
251
- if sys.platform == "win32":
252
- os.startfile(export_image) # nosec: B606 # noqa: S606
253
- else:
254
- opener = "open" if sys.platform == "darwin" else "xdg-open"
255
- subprocess.check_call(
256
- [opener, export_image] # nosec: B603 # noqa: S603
257
- )
245
+ opener = "open" if sys.platform == "darwin" else "xdg-open"
246
+ subprocess.check_call([opener, export_image]) # nosec: B603 # noqa: S603
258
247
 
259
248
  def send_table(
260
249
  self,
@@ -427,7 +416,7 @@ async def download_plotly_js():
427
416
  # we use aiohttp to download plotly.js
428
417
  # this is so we don't have to block the main thread
429
418
  async with aiohttp.ClientSession(
430
- connector=aiohttp.TCPConnector(verify_ssl=False)
419
+ connector=aiohttp.TCPConnector(verify_ssl=False), trust_env=True
431
420
  ) as session, session.get(f"https://cdn.plot.ly/{js_filename}") as resp:
432
421
  with open(str(PLOTLYJS_PATH), "wb") as f:
433
422
  while True:
@@ -1,37 +1,14 @@
1
1
  """Dummy backend for charting to avoid import errors."""
2
2
 
3
3
  import asyncio
4
- import warnings
5
4
  from queue import Queue
6
5
  from typing import List
7
6
 
8
7
  import dotenv
9
8
  from openbb_core.app.constants import OPENBB_DIRECTORY
10
- from openbb_core.env import Env
11
9
 
12
10
  SETTINGS_ENV_FILE = OPENBB_DIRECTORY / ".env"
13
11
 
14
- pywry_missing = """
15
- [red]PyWry is not installed or missing required linux dependencies.[/]
16
-
17
- [yellow]Install PyWry[/]
18
- [green]pip install pywry --upgrade[/]
19
-
20
- [yellow]Platform-specific notes[/]
21
- Here is the underlying web engine each platform uses you might need to install.
22
-
23
- [green]Linux[/]
24
- Pywry uses gtk-rs and its related libraries for window creation and Wry also needs WebKitGTK for WebView.
25
- To activate interactive plots/tables in pywry window, please make sure the following packages are installed:
26
-
27
- [yellow]Arch Linux / Manjaro:[/]
28
- [green]sudo pacman -S webkit2gtk[/]\n
29
- [yellow]Debian / Ubuntu:[/]
30
- [green]sudo apt install libwebkit2gtk-4.0-dev[/]\n
31
- [yellow]Fedora / CentOS / AlmaLinux:[/]
32
- [green]sudo dnf install gtk3-devel webkit2gtk3-devel[/]\r
33
- """
34
-
35
12
 
36
13
  class DummyBackend:
37
14
  """Dummy class to avoid import errors."""
@@ -63,8 +40,6 @@ class DummyBackend:
63
40
  self.loop = asyncio.new_event_loop()
64
41
  asyncio.set_event_loop(self.loop)
65
42
 
66
- if Env().DEBUG_MODE:
67
- warnings.warn(pywry_missing)
68
43
  dotenv.set_key(SETTINGS_ENV_FILE, "PLOT_ENABLE_PYWRY", "0")
69
44
 
70
45
  def close(self, reset: bool = False): # pylint: disable=W0613
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "openbb-charting"
3
- version = "2.2.0"
3
+ version = "2.2.2"
4
4
  description = "Charting extension for OpenBB"
5
5
  authors = ["OpenBB Team <hello@openbb.co>"]
6
6
  license = "AGPL-3.0-only"
@@ -12,12 +12,15 @@ python = ">=3.9,<3.13" # scipy forces python <4.0 explicitly
12
12
  scipy = "^1.10.0"
13
13
  plotly = "^5.17.0"
14
14
  statsmodels = "^0.14.0"
15
- pywry = "^0.6.1"
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.0"
18
+ openbb-core = "^1.3.2"
19
19
  numpy = "^1"
20
20
 
21
+ [tool.poetry.extras]
22
+ pywry = ["pywry"]
23
+
21
24
  [build-system]
22
25
  requires = ["poetry-core"]
23
26
  build-backend = "poetry.core.masonry.api"