コード例 #1
0
def pred_menu(df_stock, s_ticker, s_start, s_interval):

    # Add list of arguments that the prediction techniques parser accepts
    pred_parser = argparse.ArgumentParser(prog="pred", add_help=False)
    choices = [
        "help",
        "q",
        "quit",
        "sma",
        "ets",
        "knn",
        "linear",
        "quadratic",
        "cubic",
        "regression",
        "arima",
        "prophet",
        "mlp",
        "rnn",
        "lstm",
    ]
    pred_parser.add_argument("cmd", choices=choices)
    completer = NestedCompleter.from_nested_dict({c: None for c in choices})

    print_prediction(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()} (pred)> ",
                completer=completer,
            )
        else:
            as_input = input(f"{get_flair()} (pred)> ")

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

        # Parse prediction techniques command of the list of possible commands
        try:
            (ns_known_args, l_args) = pred_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_prediction(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

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

        elif ns_known_args.cmd == "ets":
            ets.exponential_smoothing(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "knn":
            knn.k_nearest_neighbors(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "linear":
            regression.regression(l_args, s_ticker, df_stock, regression.LINEAR)

        elif ns_known_args.cmd == "quadratic":
            regression.regression(l_args, s_ticker, df_stock, regression.QUADRATIC)

        elif ns_known_args.cmd == "cubic":
            regression.regression(l_args, s_ticker, df_stock, regression.CUBIC)

        elif ns_known_args.cmd == "regression":
            regression.regression(l_args, s_ticker, df_stock, regression.USER_INPUT)

        elif ns_known_args.cmd == "arima":
            arima.arima(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "prophet":
            fbprophet.fbprophet(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "mlp":
            neural_networks.mlp(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "rnn":
            neural_networks.rnn(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "lstm":
            neural_networks.lstm(l_args, s_ticker, df_stock)

        else:
            print("Command not recognized!")
コード例 #2
0
 def call_regression(self, other_args: List[str]):
     """Process regression command"""
     regression.regression(other_args, self.ticker, self.stock,
                           regression.USER_INPUT)
コード例 #3
0
 def call_quadratic(self, other_args: List[str]):
     """Process quadratic command"""
     regression.regression(other_args, self.ticker, self.stock,
                           regression.QUADRATIC)
コード例 #4
0
 def call_cubic(self, other_args: List[str]):
     """Process cubic command"""
     regression.regression(other_args, self.ticker, self.stock,
                           regression.CUBIC)
コード例 #5
0
 def call_linear(self, other_args: List[str]):
     """Process linear command"""
     regression.regression(other_args, self.ticker, self.stock,
                           regression.LINEAR)