mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Fix chart-related mypy errors. Co-Author: ’hjoaquim’
This commit is contained in:
@@ -142,7 +142,7 @@ class Backend(PyWry):
|
||||
|
||||
def get_json_update(
|
||||
self,
|
||||
cmd_loc: str,
|
||||
cmd_loc: Optional[str] = None,
|
||||
theme: Optional[str] = None,
|
||||
) -> dict:
|
||||
"""Get the json update for the backend."""
|
||||
|
||||
@@ -5,10 +5,7 @@ import numpy as np
|
||||
import pandas as pd
|
||||
from openbb_charting.core.config.openbb_styles import PLT_FIB_COLORWAY
|
||||
from openbb_charting.core.openbb_figure import OpenBBFigure
|
||||
from openbb_charting.core.plotly_ta.base import (
|
||||
PltTA,
|
||||
indicator,
|
||||
)
|
||||
from openbb_charting.core.plotly_ta.base import PltTA, indicator
|
||||
|
||||
|
||||
class Custom(PltTA):
|
||||
@@ -122,7 +119,6 @@ class Custom(PltTA):
|
||||
@indicator()
|
||||
def plot_fib(self, fig: OpenBBFigure, df_ta: pd.DataFrame):
|
||||
"""Add fibonacci to plotly figure."""
|
||||
|
||||
try:
|
||||
from openbb_ta.ta_helpers import calculate_fib_levels
|
||||
except ImportError:
|
||||
@@ -135,6 +131,7 @@ class Custom(PltTA):
|
||||
limit = self.params["fib"].get_argument_values("limit") or 120
|
||||
start_date = self.params["fib"].get_argument_values("start_date") or None
|
||||
end_date = self.params["fib"].get_argument_values("end_date") or None
|
||||
close = self.params["fib"].get_argument_values("close") or "close"
|
||||
(
|
||||
df_fib,
|
||||
min_date,
|
||||
@@ -142,7 +139,7 @@ class Custom(PltTA):
|
||||
min_pr,
|
||||
max_pr,
|
||||
lvl_text,
|
||||
) = calculate_fib_levels(df_ta, limit, start_date, end_date)
|
||||
) = calculate_fib_levels(df_ta, close, limit, start_date, end_date)
|
||||
levels = df_fib.Price
|
||||
fibs = [
|
||||
"<b>0</b>",
|
||||
|
||||
@@ -81,7 +81,7 @@ class PlotlyTA(PltTA):
|
||||
>>> fig2.show()
|
||||
"""
|
||||
|
||||
inchart_colors: Optional[List[str]] = None
|
||||
inchart_colors: List[str] = []
|
||||
plugins: List[Type[PltTA]] = []
|
||||
df_ta: pd.DataFrame = None
|
||||
close_column: Optional[str] = "close"
|
||||
@@ -404,7 +404,8 @@ class PlotlyTA(PltTA):
|
||||
secondary_y=False,
|
||||
)
|
||||
fig.update_layout(yaxis=dict(nticks=15))
|
||||
self.inchart_colors = self.theme.get_colors()[1:]
|
||||
if self.theme:
|
||||
self.inchart_colors = self.theme.get_colors()[1:]
|
||||
|
||||
fig.set_title(symbol, x=0.5, y=0.98, xanchor="center", yanchor="top")
|
||||
return fig
|
||||
|
||||
@@ -83,8 +83,7 @@ def fib(
|
||||
start_date: Optional[str] = None,
|
||||
end_date: Optional[str] = None,
|
||||
) -> OBBject[List[Data]]:
|
||||
"""
|
||||
Fibonacci Retracement Levels.
|
||||
"""Create Fibonacci Retracement Levels.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from importlib import import_module
|
||||
from typing import Callable, Generic, Optional, Tuple, TypeVar
|
||||
from typing import Callable, Optional, Tuple, TypeVar
|
||||
|
||||
from importlib_metadata import entry_points
|
||||
|
||||
@@ -194,7 +194,7 @@ class ChartingManager(metaclass=SingletonMeta):
|
||||
user_settings: UserSettings,
|
||||
system_settings: SystemSettings,
|
||||
route: str,
|
||||
obbject_item: Generic[T],
|
||||
obbject_item: T,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
|
||||
@@ -16,8 +16,6 @@ class ChartingSettings:
|
||||
user_settings = user_settings or UserSettings()
|
||||
system_settings = system_settings or SystemSettings()
|
||||
|
||||
has_hub = user_settings.profile.hub_session is not None
|
||||
|
||||
user_data_directory = (
|
||||
str(Path.home() / "OpenBBUserData")
|
||||
if not user_settings.preferences
|
||||
@@ -37,11 +35,11 @@ class ChartingSettings:
|
||||
self.plot_pywry_width: int = user_settings.preferences.plot_pywry_width
|
||||
self.plot_pywry_height: int = user_settings.preferences.plot_pywry_height
|
||||
self.plot_open_export: bool = user_settings.preferences.plot_open_export
|
||||
self.user_email: Optional[str] = (
|
||||
user_settings.profile.hub_session.email if has_hub else None
|
||||
self.user_email: Optional[str] = getattr(
|
||||
user_settings.profile.hub_session, "email", None
|
||||
)
|
||||
self.user_uuid: Optional[str] = (
|
||||
user_settings.profile.hub_session.user_uuid if has_hub else None
|
||||
self.user_uuid: Optional[str] = getattr(
|
||||
user_settings.profile.hub_session, "uuid", None
|
||||
)
|
||||
self.user_exports_directory = user_settings.preferences.export_directory
|
||||
self.user_styles_directory = user_settings.preferences.user_styles_directory
|
||||
|
||||
Reference in New Issue
Block a user