def call_rolling(self, other_args: List[str]):
     """Process rolling command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="rolling",
         description="""
             Rolling mean and std deviation
         """,
     )
     parser.add_argument(
         "-w",
         "--window",
         action="store",
         dest="n_window",
         type=check_positive,
         default=14,
         help="Window length",
     )
     ns_parser = parse_known_args_and_warn(
         parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED)
     if ns_parser:
         rolling_view.display_mean_std(
             name=self.ticker,
             df=self.df,
             target=self.target,
             window=ns_parser.n_window,
             export=ns_parser.export,
         )
示例#2
0
    def call_rolling(self, other_args: List[str]):
        """Process rolling command"""

        parser = argparse.ArgumentParser(
            add_help=False,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            prog="rolling",
            description="""
                Rolling mean and std deviation
            """,
        )
        parser.add_argument(
            "-l",
            "--length",
            action="store",
            dest="n_length",
            type=check_positive,
            default=14,
            help="Window length",
        )
        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

            rolling_view.display_mean_std(
                name=self.ticker,
                df=self.stock,
                target=self.target,
                length=ns_parser.n_length,
                export=ns_parser.export,
            )

        except Exception as e:
            print(e, "\n")