def call_sentiment(self, other_args: List[str]): """Process sentiment command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="sentiment_compare", description=""" FinBrain's sentiment comparison across similar tickers. """, ) parser.add_argument( "-r", "--raw", action="store_true", default=False, help="Display raw sentiment data", dest="raw", ) ns_parser = parse_known_args_and_warn( parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) if ns_parser: if self.similar and len(self.similar) > 1: finbrain_view.display_sentiment_compare( similar=self.similar, raw=ns_parser.raw, export=ns_parser.export, ) else: console.print( "Please make sure there are more than 1 similar tickers selected. \n" )
def test_display_sentiment_compare(raw, mocker): mocker.patch.object(target=finbrain_view.gtff, attribute="USE_ION", new=False) mocker.patch("matplotlib.pyplot.show") finbrain_view.display_sentiment_compare( similar=["TSLA", "GM"], raw=raw, export="", )
def test_display_sentiment_compare(raw, mocker): # MOCK VISUALIZE_OUTPUT mocker.patch( target= "gamestonk_terminal.helper_classes.TerminalStyle.visualize_output") finbrain_view.display_sentiment_compare( similar=["TSLA", "GM"], raw=raw, export="", )
def call_sentiment(self, other_args: List[str]): """Process sentiment command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="sentiment_compare", description=""" FinBrain's sentiment comparison across similar tickers. """, ) parser.add_argument( "-r", "--raw", action="store_true", default=False, help="Display raw sentiment data", dest="raw", ) parser.add_argument( "--export", choices=["csv", "json", "xlsx"], default="", type=str, dest="export", help="Export dataframe data to csv,json,xlsx file", ) try: ns_parser = parse_known_args_and_warn(parser, other_args) if not ns_parser: return finbrain_view.display_sentiment_compare( ticker=self.ticker, similar=self.similar, raw=ns_parser.raw, export=ns_parser.export, ) except Exception as e: print(e, "\n")