sdk powered working commands on stocks menu

This commit is contained in:
hjoaquim
2023-07-30 11:13:15 +01:00
parent 35a068c6d4
commit ee32c67eae

View File

@@ -21,6 +21,7 @@ from openbb_terminal.helper_funcs import (
EXPORT_BOTH_RAW_DATA_AND_FIGURES,
EXPORT_ONLY_RAW_DATA_ALLOWED,
export_data,
print_rich_table,
)
from openbb_terminal.menu import session
from openbb_terminal.parent_classes import StockBaseController
@@ -564,11 +565,29 @@ class StocksController(StockBaseController):
if c_out.error:
console.print(f"[red]{c_out.error}[/]\n")
else:
console.print(c_out.results)
sheet_name = (
" ".join(ns_parser.sheet_name) if ns_parser.sheet_name else None
)
export = ns_parser.export if ns_parser.export else None
if ns_parser.chart:
# TODO : charting needs to be implemented on the sdk
c_out.show()
print_rich_table(
df=c_out.to_dataframe(),
show_index=True,
title="News",
index_name="Date",
export=bool(export),
)
export_data(
export_type=export,
dir_path=os.path.dirname(os.path.abspath(__file__)),
func_name="news",
df=c_out.to_dataframe(),
sheet_name=sheet_name,
)
# TODO : charting needs to be implemented on the sdk
# if ns_parser.chart:
# c_out.show()
@log_start_end(log=logger)
def call_multiples(self, other_args: List[str]):
@@ -578,18 +597,38 @@ class StocksController(StockBaseController):
parser = translator.parser
if ns_parser := self.parse_known_args_and_warn(
parser=parser, other_args=other_args
parser=parser,
other_args=other_args,
export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED,
):
c_out = translator.execute_func(parsed_args=ns_parser)
if c_out.error:
console.print(f"[red]{c_out.error}[/]\n")
else:
console.print(c_out.results)
sheet_name = (
" ".join(ns_parser.sheet_name) if ns_parser.sheet_name else None
)
export = ns_parser.export if ns_parser.export else None
if ns_parser.chart:
# TODO : charting needs to be implemented on the sdk
c_out.show()
print_rich_table(
df=c_out.to_dataframe(),
show_index=True,
title=f"Multiples",
index_name="Metric",
export=bool(export),
)
export_data(
export_type=export,
dir_path=os.path.dirname(os.path.abspath(__file__)),
func_name="multiples",
df=c_out.to_dataframe(),
sheet_name=sheet_name,
)
# TODO : charting needs to be implemented on the sdk
# if ns_parser.chart:
# c_out.show()
@log_start_end(log=logger)
def call_disc(self, _):