def call_scorr(self, other_args: List[str]): """Process sentiment correlation command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="sentiment_compare", description=""" FinBrain's sentiment correlation 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_correlation( similar=self.similar, raw=ns_parser.raw, export=ns_parser.export, ) else: console.print("Please make sure there are similar tickers selected. \n")
def test_display_sentiment_correlation(raw, mocker): mocker.patch.object(target=finbrain_view.gtff, attribute="USE_ION", new=False) mocker.patch("matplotlib.pyplot.show") finbrain_view.display_sentiment_correlation( similar=["TSLA", "GM"], raw=raw, export="", )
def test_display_sentiment_correlation(raw, mocker): # MOCK VISUALIZE_OUTPUT mocker.patch( target= "gamestonk_terminal.helper_classes.TerminalStyle.visualize_output") finbrain_view.display_sentiment_correlation( similar=["TSLA", "GM"], raw=raw, export="", )
def call_scorr(self, other_args: List[str]): """Process sentiment correlation command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="sentiment_compare", description=""" FinBrain's sentiment correlation 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 if not self.similar or not self.ticker: print( "Please make sure there are both a loaded ticker and similar tickers selected. \n" ) return finbrain_view.display_sentiment_correlation( ticker=self.ticker, similar=self.similar, raw=ns_parser.raw, export=ns_parser.export, ) except Exception as e: print(e, "\n")