def call_softs(self, other_args: List[str]):
     """Process softs command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="softs",
         description="Softs future overview. [Source: Finviz]",
     )
     parser.add_argument(
         "-s",
         "--sortby",
         dest="sort_col",
         type=str,
         choices=self.wsj_sortby_cols_dict.keys(),
         default="ticker",
     )
     parser.add_argument(
         "-a",
         "-ascend",
         dest="ascend",
         help="Flag to sort in ascending order",
         action="store_true",
         default=False,
     )
     ns_parser = parse_known_args_and_warn(
         parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED)
     if ns_parser:
         finviz_view.display_future(
             future_type="Softs",
             sort_col=ns_parser.sort_col,
             ascending=ns_parser.ascend,
             export=ns_parser.export,
         )
    def call_futures(self, other_args: List[str]):
        """Process futures command"""
        parser = argparse.ArgumentParser(
            add_help=False,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            prog="futures",
            description="Futures/Commodities from Wall St. Journal and FinViz.",
        )

        parser.add_argument(
            "-c",
            "--commodity",
            dest="commodity",
            help="Obtain commodity futures from FinViz",
            type=str,
            choices=["energy", "metals", "meats", "grains", "softs"],
            default="",
        )

        parser.add_argument(
            "-s",
            "--sortby",
            dest="sort_col",
            type=str,
            choices=self.wsj_sortby_cols_dict.keys(),
            default="ticker",
        )
        parser.add_argument(
            "-a",
            "-ascend",
            dest="ascend",
            help="Flag to sort in ascending order",
            action="store_true",
            default=False,
        )

        if other_args and "-" not in other_args[0][0]:
            other_args.insert(0, "-c")
        ns_parser = parse_known_args_and_warn(
            parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED)

        if ns_parser and ns_parser.commodity:
            finviz_view.display_future(
                future_type=ns_parser.commodity.capitalize(),
                sort_col=ns_parser.sort_col,
                ascending=ns_parser.ascend,
                export=ns_parser.export,
            )
        elif ns_parser:
            wsj_view.display_futures(export=ns_parser.export, )
Exemple #3
0
def test_display_future(mocker, tab):
    # MOCK GTFF
    mocker.patch.object(target=helper_funcs.gtff,
                        attribute="USE_TABULATE_DF",
                        new=tab)
    mocker.patch.object(target=helper_funcs.gtff,
                        attribute="USE_ION",
                        new=True)

    # MOCK EXPORT_DATA
    mocker.patch(target="gamestonk_terminal.economy.finviz_view.export_data")

    finviz_view.display_future(
        future_type="Indices",
        sort_col="ticker",
        ascending=False,
        export="",
    )