From 10602b7a4d0047cc3398f69fc56120afe7e05a9e Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Wed, 9 Aug 2023 18:12:58 +0100 Subject: [PATCH] fixing news --- openbb_terminal/stocks/stocks_controller.py | 111 ++++++++++---------- 1 file changed, 54 insertions(+), 57 deletions(-) diff --git a/openbb_terminal/stocks/stocks_controller.py b/openbb_terminal/stocks/stocks_controller.py index a99d6f88883..7c85fddca1f 100644 --- a/openbb_terminal/stocks/stocks_controller.py +++ b/openbb_terminal/stocks/stocks_controller.py @@ -548,46 +548,44 @@ class StocksController(StockBaseController): else: console.print("No ticker loaded. First use 'load '") - # @log_start_end(log=logger) - # def call_news(self, other_args: List[str]): - # """Process news command.""" - # translator = stocks_translations.get_translator(menu="stocks", command="news") - # parser = translator.parser + @log_start_end(log=logger) + def call_news(self, other_args: List[str]): + """Process news command.""" + translator = stocks_translations.get_translator(menu="stocks", command="news") + parser = translator.parser - # if ns_parser := self.parse_known_args_and_warn( - # parser=parser, - # other_args=other_args, - # export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED, - # limit=10, - # ): - # c_out = translator.execute_func(parsed_args=ns_parser) + if ns_parser := self.parse_known_args_and_warn( + 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: - # 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 c_out.error: + console.print(f"[red]{c_out.error}[/]\n") + else: + # sheet_name = ( + # " ".join(ns_parser.sheet_name) if ns_parser.sheet_name else None + # ) + # export = ns_parser.export if ns_parser.export else None - # 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, - # ) + # 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() + if ns_parser.chart: + c_out.show() @log_start_end(log=logger) def call_multiples(self, other_args: List[str]): @@ -606,29 +604,28 @@ class StocksController(StockBaseController): if c_out.error: console.print(f"[red]{c_out.error}[/]\n") else: - sheet_name = ( - " ".join(ns_parser.sheet_name) if ns_parser.sheet_name else None - ) - export = ns_parser.export if ns_parser.export else None + # sheet_name = ( + # " ".join(ns_parser.sheet_name) if ns_parser.sheet_name else None + # ) + # export = ns_parser.export if ns_parser.export else None - 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, - ) + # 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() + if ns_parser.chart: + c_out.show() @log_start_end(log=logger) def call_disc(self, _):