示例#1
0
 def call_aroon(self, other_args: List[str]):
     """Process aroon command"""
     ta_trend.aroon(other_args, self.ticker, self.interval, self.stock)
示例#2
0
def ta_menu(df_stock, s_ticker, s_start, s_interval):

    # Add list of arguments that the technical analysis parser accepts
    ta_parser = argparse.ArgumentParser(prog="ta", add_help=False)
    choices = [
        "help",
        "q",
        "quit",
        "ema",
        "sma",
        "vwap",
        "cci",
        "macd",
        "rsi",
        "stoch",
        "adx",
        "aroon",
        "bbands",
        "ad",
        "obv",
    ]
    ta_parser.add_argument("cmd", choices=choices)
    completer = NestedCompleter.from_nested_dict({c: None for c in choices})

    print_technical_analysis(s_ticker, s_start, s_interval)

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

        # Images are non blocking - allows to close them if we type other command
        plt.close()

        # Parse fundamental analysis command of the list of possible commands
        try:
            (ns_known_args,
             l_args) = ta_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_technical_analysis(s_ticker, s_start, s_interval)

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

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

        # OVERLAP
        elif ns_known_args.cmd == "ema":
            ta_overlap.ema(l_args, s_ticker, s_interval, df_stock)

        elif ns_known_args.cmd == "sma":
            ta_overlap.sma(l_args, s_ticker, s_interval, df_stock)

        elif ns_known_args.cmd == "vwap":
            ta_overlap.vwap(l_args, s_ticker, s_interval, df_stock)

        # MOMENTUM
        elif ns_known_args.cmd == "cci":
            ta_momentum.cci(l_args, s_ticker, s_interval, df_stock)

        elif ns_known_args.cmd == "macd":
            ta_momentum.macd(l_args, s_ticker, s_interval, df_stock)

        elif ns_known_args.cmd == "rsi":
            ta_momentum.rsi(l_args, s_ticker, s_interval, df_stock)

        elif ns_known_args.cmd == "stoch":
            ta_momentum.stoch(l_args, s_ticker, s_interval, df_stock)

        # TREND
        elif ns_known_args.cmd == "adx":
            ta_trend.adx(l_args, s_ticker, s_interval, df_stock)

        elif ns_known_args.cmd == "aroon":
            ta_trend.aroon(l_args, s_ticker, s_interval, df_stock)

        # VOLATILITY
        elif ns_known_args.cmd == "bbands":
            ta_volatility.bbands(l_args, s_ticker, s_interval, df_stock)

        # VOLUME
        elif ns_known_args.cmd == "ad":
            ta_volume.ad(l_args, s_ticker, s_interval, df_stock)

        elif ns_known_args.cmd == "obv":
            ta_volume.obv(l_args, s_ticker, s_interval, df_stock)

        else:
            print("Command not recognized!")