mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-25 18:53:26 +00:00
cleanup
This commit is contained in:
@@ -1819,7 +1819,7 @@ def stocks_load(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
|
||||
k["rma"] = dict(length=ma)
|
||||
return k
|
||||
|
||||
data = basemodel_to_df(kwargs["OBBject_item"], index=kwargs.get("index", "date"))
|
||||
data = basemodel_to_df(kwargs["obbject_item"], index=kwargs.get("index", "date"))
|
||||
standard_params = kwargs["standard_params"].__dict__
|
||||
ma = standard_params.get("ma", None)
|
||||
prepost = standard_params.get("prepost", False)
|
||||
@@ -1838,7 +1838,7 @@ def stocks_load(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
|
||||
|
||||
|
||||
def stocks_news(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
|
||||
data = basemodel_to_df(kwargs["OBBject_item"], index=kwargs.get("index", "date"))
|
||||
data = basemodel_to_df(kwargs["obbject_item"], index=kwargs.get("index", "date"))
|
||||
standard_params = kwargs["standard_params"].__dict__
|
||||
columnwidth = standard_params.get("columnwidth", None)
|
||||
|
||||
@@ -2104,7 +2104,7 @@ def stocks_ins_filt(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
|
||||
|
||||
|
||||
def stocks_multiples(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
|
||||
data = basemodel_to_df(kwargs["OBBject_item"], index=kwargs.get("index", "date"))
|
||||
data = basemodel_to_df(kwargs["obbject_item"], index=kwargs.get("index", "date"))
|
||||
standard_params = kwargs["standard_params"].__dict__
|
||||
columnwidth = standard_params.get("columnwidth", None)
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ class ChartingManager(metaclass=SingletonMeta):
|
||||
user_settings: UserSettings,
|
||||
system_settings: SystemSettings,
|
||||
route: str,
|
||||
OBBject_item: Generic[T],
|
||||
obbject_item: Generic[T],
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
@@ -215,7 +215,7 @@ class ChartingManager(metaclass=SingletonMeta):
|
||||
User settings.
|
||||
route : str
|
||||
Route name, example: `/stocks/load`.
|
||||
OBBject_item
|
||||
obbject_item
|
||||
Command output item.
|
||||
Returns
|
||||
-------
|
||||
@@ -235,7 +235,7 @@ class ChartingManager(metaclass=SingletonMeta):
|
||||
|
||||
self.handle_backend(self._charting_extension, self._charting_settings)
|
||||
|
||||
kwargs["OBBject_item"] = OBBject_item
|
||||
kwargs["obbject_item"] = obbject_item
|
||||
kwargs["charting_settings"] = self._charting_settings
|
||||
|
||||
charting_function = self.get_chart_function(self._charting_extension, route)
|
||||
|
||||
@@ -228,8 +228,8 @@ class ParametersBuilder:
|
||||
|
||||
|
||||
class StaticCommandRunner:
|
||||
logging_manager = LoggingManager()
|
||||
charting_manager = ChartingManager()
|
||||
logging_manager: LoggingManager = LoggingManager()
|
||||
charting_manager: ChartingManager = ChartingManager()
|
||||
|
||||
@staticmethod
|
||||
def __run_in_isolation(func, args=None, kwargs=None) -> OBBject:
|
||||
@@ -255,21 +255,21 @@ class StaticCommandRunner:
|
||||
|
||||
with context_manager as warning_list:
|
||||
if system_settings.run_in_isolation:
|
||||
OBBject = cls.__run_in_isolation(func=func, kwargs=kwargs)
|
||||
obbject = cls.__run_in_isolation(func=func, kwargs=kwargs)
|
||||
else:
|
||||
OBBject = func(**kwargs)
|
||||
obbject = func(**kwargs)
|
||||
|
||||
OBBject.provider = getattr(
|
||||
obbject.provider = getattr(
|
||||
kwargs.get("provider_choices", None), "provider", None
|
||||
)
|
||||
|
||||
if warning_list:
|
||||
OBBject.warnings = list(map(cast_warning, warning_list))
|
||||
obbject.warnings = list(map(cast_warning, warning_list))
|
||||
|
||||
except Exception as e:
|
||||
raise OpenBBError(e) from e
|
||||
|
||||
return OBBject
|
||||
return obbject
|
||||
|
||||
@classmethod
|
||||
def __chart(
|
||||
@@ -282,15 +282,15 @@ class StaticCommandRunner:
|
||||
) -> None:
|
||||
"""Create a chart from the command output"""
|
||||
try:
|
||||
OBBject.chart = cls.charting_manager.chart(
|
||||
obbject.chart = cls.charting_manager.chart(
|
||||
user_settings=user_settings,
|
||||
system_settings=system_settings,
|
||||
route=route,
|
||||
OBBject_item=obbject.results,
|
||||
obbject_item=obbject.results,
|
||||
**kwargs,
|
||||
)
|
||||
except Exception as e:
|
||||
OBBject.chart = Chart(error=Error(message=str(e)))
|
||||
obbject.chart = Chart(error=Error(message=str(e)))
|
||||
if system_settings.debug_mode:
|
||||
raise
|
||||
|
||||
@@ -328,15 +328,15 @@ class StaticCommandRunner:
|
||||
# commands.py and the function signature does not expect "chart"
|
||||
kwargs.pop("chart", None)
|
||||
|
||||
OBBject = cls.__command(
|
||||
obbject = cls.__command(
|
||||
system_settings=system_settings,
|
||||
func=func,
|
||||
kwargs=kwargs,
|
||||
)
|
||||
|
||||
if chart and OBBject.results:
|
||||
if chart and obbject.results:
|
||||
cls.__chart(
|
||||
OBBject=OBBject,
|
||||
obbject=obbject,
|
||||
user_settings=user_settings,
|
||||
system_settings=system_settings,
|
||||
route=route,
|
||||
@@ -346,13 +346,13 @@ class StaticCommandRunner:
|
||||
cls.logging_manager.log(
|
||||
user_settings=user_settings,
|
||||
system_settings=system_settings,
|
||||
OBBject=OBBject,
|
||||
obbject=obbject,
|
||||
route=route,
|
||||
func=func,
|
||||
kwargs=kwargs,
|
||||
)
|
||||
|
||||
return OBBject
|
||||
return obbject
|
||||
|
||||
@classmethod
|
||||
def __update_managers_settings(
|
||||
@@ -384,7 +384,7 @@ class StaticCommandRunner:
|
||||
func = command_map.get_command(route=route)
|
||||
|
||||
if func:
|
||||
OBBject = cls.__execute_func(
|
||||
obbject = cls.__execute_func(
|
||||
route=route,
|
||||
args=args, # type: ignore
|
||||
execution_context=execution_context,
|
||||
@@ -400,7 +400,7 @@ class StaticCommandRunner:
|
||||
journal_id=journal.id,
|
||||
arguments=kwargs,
|
||||
duration=duration,
|
||||
output=OBBject,
|
||||
output=obbject,
|
||||
route=route,
|
||||
timestamp=timestamp,
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ class LoggingManager(metaclass=SingletonMeta):
|
||||
__init__(system_settings, user_settings)
|
||||
Logging Manager Constructor.
|
||||
|
||||
log(user_settings, system_settings, OBBject, route, func, kwargs)
|
||||
log(user_settings, system_settings, obbject, route, func, kwargs)
|
||||
Log command output and relevant information.
|
||||
|
||||
logging_settings
|
||||
|
||||
@@ -245,7 +245,7 @@ class DocstringGenerator:
|
||||
@staticmethod
|
||||
def get_object_description() -> str:
|
||||
"""Get the command output description."""
|
||||
OBBject_description = (
|
||||
obbject_description = (
|
||||
"\nReturns\n"
|
||||
"-------\n"
|
||||
"OBBject\n"
|
||||
@@ -261,7 +261,7 @@ class DocstringGenerator:
|
||||
" Chart object.\n"
|
||||
)
|
||||
|
||||
return OBBject_description
|
||||
return obbject_description
|
||||
|
||||
@staticmethod
|
||||
def get_available_providers(query_mapping: dict) -> str:
|
||||
|
||||
@@ -103,7 +103,7 @@ def test_log_startup(logging_manager):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"user_settings, system_settings, OBBject, route, func, kwargs",
|
||||
"user_settings, system_settings, obbject, route, func, kwargs",
|
||||
[
|
||||
(
|
||||
"mock_settings",
|
||||
@@ -132,7 +132,7 @@ def test_log_startup(logging_manager):
|
||||
],
|
||||
)
|
||||
def test_log(
|
||||
logging_manager, user_settings, system_settings, OBBject, route, func, kwargs
|
||||
logging_manager, user_settings, system_settings, obbject, route, func, kwargs
|
||||
):
|
||||
with patch(
|
||||
"openbb_core.app.logs.logging_manager.LoggingSettings",
|
||||
@@ -145,7 +145,7 @@ def test_log(
|
||||
logging_manager.log(
|
||||
user_settings=user_settings,
|
||||
system_settings=system_settings,
|
||||
OBBject=OBBject,
|
||||
obbject=obbject,
|
||||
route=route,
|
||||
func=func,
|
||||
kwargs=kwargs,
|
||||
@@ -162,7 +162,7 @@ def test_log(
|
||||
logging_manager.log(
|
||||
user_settings=user_settings,
|
||||
system_settings=system_settings,
|
||||
OBBject=OBBject,
|
||||
obbject=obbject,
|
||||
route=route,
|
||||
func=mock_callable,
|
||||
kwargs=kwargs,
|
||||
@@ -171,10 +171,10 @@ def test_log(
|
||||
expected_log_data = {
|
||||
"route": route,
|
||||
"input": kwargs,
|
||||
"error": OBBject.error,
|
||||
"error": obbject.error,
|
||||
}
|
||||
|
||||
if OBBject.error:
|
||||
if obbject.error:
|
||||
mock_error.assert_called_once_with(
|
||||
"ERROR: %s",
|
||||
json.dumps(expected_log_data),
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
"""Common descriptions for model fields."""
|
||||
|
||||
QUERY_DESCRIPTIONS = {
|
||||
"symbol": "Symbol to get data for.",
|
||||
"start_date": "Start date of the data, in YYYY-MM-DD format.",
|
||||
"end_date": "End date of the data, in YYYY-MM-DD format.",
|
||||
"weekly": "Whether to return weekly data.",
|
||||
"monthly": "Whether to return monthly data.",
|
||||
"period": "Period of the data to return (quarterly or annually).",
|
||||
"date": "A specific date to get data for.",
|
||||
"limit": "The number of data entries to return.",
|
||||
"countries": "The country or countries to get data.",
|
||||
"units": "The data units.",
|
||||
"frequency": "The data time frequency.",
|
||||
}
|
||||
|
||||
DATA_DESCRIPTIONS = {
|
||||
"symbol": "Symbol representing the entity requested in the data.",
|
||||
"date": "The date of the data.",
|
||||
"open": "The open price of the symbol.",
|
||||
"high": "The high price of the symbol.",
|
||||
"low": "The low price of the symbol.",
|
||||
"close": "The close price of the symbol.",
|
||||
"volume": "The volume of the symbol.",
|
||||
"adj_close": "The adjusted close price of the symbol.",
|
||||
"vwap": "Volume Weighted Average Price of the symbol.",
|
||||
}
|
||||
Reference in New Issue
Block a user