def call_psi(self, other_args: List[str]): """Process psi command""" parser = argparse.ArgumentParser( prog="psi", add_help=False, description= "Shows price vs short interest volume. [Source: Quandl/Stockgrid]", ) parser.add_argument( "--source", choices=["quandl", "stockgrid"], default="", dest="stockgrid", help="Source of short interest volume", ) if "quandl" in other_args: parser.add_argument( "--nyse", action="store_true", default=False, dest="b_nyse", help="Data from NYSE flag. Otherwise comes from NASDAQ.", ) parser.add_argument( "-n", "--number", help="Number of last open market days to show", type=check_positive, default=10 if "-r" in other_args else 120, dest="num", ) parser.add_argument( "-r", "--raw", action="store_true", default=False, help="Flag to print raw data instead", dest="raw", ) ns_parser = parse_known_args_and_warn(parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED) if ns_parser: if self.ticker: if "quandl" in other_args: quandl_view.short_interest( ticker=self.ticker, nyse=ns_parser.b_nyse, days=ns_parser.num, raw=ns_parser.raw, export=ns_parser.export, ) else: stockgrid_view.short_interest_volume( ticker=self.ticker, num=ns_parser.num, raw=ns_parser.raw, export=ns_parser.export, ) else: console.print("No ticker loaded.\n")
def test_short_interest_volume(mocker, raw): mocker.patch.object(target=stockgrid_view, attribute="USE_ION", new=False) mocker.patch("matplotlib.pyplot.show") stockgrid_view.short_interest_volume( ticker="PM", num=2, raw=raw, export="", )
def test_short_interest_volume(mocker, raw): # MOCK VISUALIZE_OUTPUT mocker.patch( target= "gamestonk_terminal.helper_classes.TerminalStyle.visualize_output") stockgrid_view.short_interest_volume( ticker="PM", num=2, raw=raw, export="", )
def call_psi(self, other_args: List[str]): """Process psi command""" parser = argparse.ArgumentParser( prog="psi", add_help=False, description= "Shows price vs short interest volume. [Source: Quandl/Stockgrid]", ) parser.add_argument( "--source", choices=["quandl", "stockgrid"], default="", dest="stockgrid", help="Source of short interest volume", ) if "quandl" in other_args: parser.add_argument( "-n", "--nyse", action="store_true", default=False, dest="b_nyse", help="Data from NYSE flag. Otherwise comes from NASDAQ.", ) parser.add_argument( "-d", "--days", action="store", dest="n_days", type=check_positive, default=10 if "-r" in other_args else 120, help="Number of latest days to print data.", ) else: parser.add_argument( "-n", "--number", help="Number of last open market days to show", type=check_positive, default=10 if "-r" in other_args else 120, dest="num", ) parser.add_argument( "-r", action="store_true", default=False, help="Flag to print raw data instead", dest="raw", ) parser.add_argument( "--export", choices=["csv", "json", "xlsx"], default="", 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.ticker: print("No ticker loaded.\n") return if "quandl" in other_args: quandl_view.short_interest( ticker=self.ticker, nyse=ns_parser.b_nyse, days=ns_parser.n_days, raw=ns_parser.raw, export=ns_parser.export, ) else: stockgrid_view.short_interest_volume( ticker=self.ticker, num=ns_parser.num, raw=ns_parser.raw, export=ns_parser.export, ) except Exception as e: print(e, "\n")