예제 #1
0
    def call_vwap(self, other_args: List[str]):
        """Process vwap command"""
        parser = argparse.ArgumentParser(
            add_help=False,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            prog="vwap",
            description="""
                The Volume Weighted Average Price that measures the average typical price
                by volume.  It is typically used with intraday charts to identify general direction.
            """,
        )

        parser.add_argument(
            "-o",
            "--offset",
            action="store",
            dest="n_offset",
            type=int,
            default=0,
            help="offset",
        )

        ns_parser = parse_known_args_and_warn(
            parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES)
        if ns_parser:
            if self.interval == "1440min":
                print("VWAP should be used with intraday data.\n")

            overlap_view.view_vwap(
                s_ticker=self.ticker,
                s_interval=self.interval,
                df_stock=self.stock,
                offset=ns_parser.n_offset,
                export=ns_parser.export,
            )
예제 #2
0
    def call_vwap(self, other_args: List[str]):
        """Process vwap command"""
        parser = argparse.ArgumentParser(
            add_help=False,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            prog="vwap",
            description="""
                The Volume Weighted Average Price that measures the average typical price
                by volume.  It is typically used with intraday charts to identify general direction.
            """,
        )

        parser.add_argument(
            "-o",
            "--offset",
            action="store",
            dest="n_offset",
            type=int,
            default=0,
            help="offset",
        )

        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

            # Daily
            if self.interval == "1440min":
                print("VWAP should be used with intraday data. \n")
                return

            overlap_view.view_vwap(
                s_ticker=self.ticker,
                s_interval=self.interval,
                df_stock=self.stock,
                offset=ns_parser.n_offset,
                export=ns_parser.export,
            )

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