def call_trending(self, other_args: List[str]):
     """Process trending command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="trending",
         description="""Trending news articles. [Source: Seeking Alpha]""",
     )
     parser.add_argument(
         "-i",
         "--id",
         action="store",
         dest="n_id",
         type=check_positive,
         default=-1,
         help="article ID",
     )
     parser.add_argument(
         "-l",
         "--limit",
         action="store",
         dest="limit",
         type=check_positive,
         default=5,
         help="limit of articles being printed",
     )
     parser.add_argument(
         "-d",
         "--date",
         action="store",
         dest="s_date",
         type=valid_date,
         default=datetime.now().strftime("%Y-%m-%d"),
         help="starting date of articles",
     )
     if other_args and "-" not in other_args[0][0]:
         other_args.insert(0, "-i")
     ns_parser = parse_known_args_and_warn(
         parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
     )
     if ns_parser:
         seeking_alpha_view.news(
             article_id=ns_parser.n_id,
             num=ns_parser.limit,
             export=ns_parser.export,
         )
Beispiel #2
0
    def call_trending(self, other_args: List[str]):
        """Process trending command"""
        parser = argparse.ArgumentParser(
            add_help=False,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            prog="trending",
            description="""Trending news articles. [Source: Seeking Alpha]""",
        )
        parser.add_argument(
            "-i",
            "--id",
            action="store",
            dest="n_id",
            type=check_positive,
            default=-1,
            help="article ID",
        )
        parser.add_argument(
            "-n",
            "--num",
            action="store",
            dest="n_num",
            type=check_positive,
            default=5,
            help="number of articles being printed",
        )
        parser.add_argument(
            "-d",
            "--date",
            action="store",
            dest="s_date",
            type=valid_date,
            default=datetime.now().strftime("%Y-%m-%d"),
            help="starting date of articles",
        )
        parser.add_argument(
            "--export",
            choices=["csv", "json", "xlsx"],
            default="",
            type=str,
            dest="export",
            help="Export dataframe data to csv,json,xlsx file",
        )
        try:
            if other_args:
                if "-" not in other_args[0]:
                    other_args.insert(0, "-i")

            ns_parser = parse_known_args_and_warn(parser, other_args)
            if not ns_parser:
                return

            seeking_alpha_view.news(
                news_type="trending",
                article_id=ns_parser.n_id,
                num=ns_parser.n_num,
                start_date=ns_parser.s_date,
                export=ns_parser.export,
            )

        except Exception as e:
            print(e, "\n")
Beispiel #3
0
def test_news():
    seeking_alpha_view.news(
        article_id=-1,
        num=2,
        export="",
    )