Beispiel #1
0
def dd_menu(df_stock, s_ticker, s_start, s_interval):

    # Add list of arguments that the due diligence parser accepts
    dd_parser = argparse.ArgumentParser(prog="dd", add_help=False)
    choices = [
        "info",
        "help",
        "q",
        "quit",
        "red",
        "short",
        "rating",
        "pt",
        "est",
        "ins",
        "insider",
        "news",
        "analyst",
        "warnings",
        "sec",
    ]
    dd_parser.add_argument("cmd", choices=choices)
    completer = NestedCompleter.from_nested_dict({c: None for c in choices})

    print_due_diligence(s_ticker, s_start, s_interval)

    # Loop forever and ever
    while True:
        # Get input command from user
        if session:
            as_input = session.prompt(
                f"{get_flair()} (dd)> ",
                completer=completer,
            )
        else:
            as_input = input(f"{get_flair()} (dd)> ")

        # Parse due diligence command of the list of possible commands
        try:
            (ns_known_args,
             l_args) = dd_parser.parse_known_args(as_input.split())

        except SystemExit:
            print("The command selected doesn't exist\n")
            continue

        if ns_known_args.cmd == "help":
            print_due_diligence(s_ticker, s_start, s_interval)

        elif ns_known_args.cmd == "q":
            # Just leave the DD menu
            return False

        elif ns_known_args.cmd == "quit":
            # Abandon the program
            return True

        # REDDIT API
        elif ns_known_args.cmd == "red":
            r_api.due_diligence(l_args, s_ticker)

        # FINVIZ API
        elif ns_known_args.cmd == "insider":
            fvz_api.insider(l_args, s_ticker)

        elif ns_known_args.cmd == "news":
            fvz_api.news(l_args, s_ticker)

        elif ns_known_args.cmd == "analyst":
            fvz_api.analyst(l_args, s_ticker)

        # BUSINESS INSIDER API
        elif ns_known_args.cmd == "pt":
            bi_api.price_target_from_analysts(l_args, df_stock, s_ticker,
                                              s_start, s_interval)

        elif ns_known_args.cmd == "est":
            bi_api.estimates(l_args, s_ticker)

        elif ns_known_args.cmd == "ins":
            bi_api.insider_activity(l_args, df_stock, s_ticker, s_start,
                                    s_interval)

        # FINANCIAL MODELING PREP API
        elif ns_known_args.cmd == "rating":
            fmp_api.rating(l_args, s_ticker)

        # MARKET WATCH API
        elif ns_known_args.cmd == "sec":
            mw_api.sec_fillings(l_args, s_ticker)

        elif ns_known_args.cmd == "warnings":
            mw_api.sean_seah_warnings(l_args, s_ticker)

        # QUANDL API
        elif ns_known_args.cmd == "short":
            q_api.short_interest(l_args, s_ticker, s_start)

        else:
            print("Command not recognized!")
Beispiel #2
0
 def test_rating(self):
     rating([], "PLTR")