Exemplo n.º 1
0
def menu_3_choose(ticker, ticker_info, user_in):
    """ processing user input for menu 3"""

    # creating lists to check user input words
    stockover_words = ['1', 'overview', 'stock overview', 'view stock']
    timeseries_words = [
        '2', 'time', 'time series', 'time-series', 'stock time',
        'time series analysis'
    ]

    # checking user input vs input lists and performing corresponding action
    if user_in.lower() in stockover_words:
        get_stock_info.print_ticker(ticker, ticker_info)

    elif user_in.lower() in timeseries_words:
        get_stock_info.load_ticker(ticker, ticker_info)

    elif user_in == "3" or user_in.lower() in backWords:
        menus.menu_2()

    elif user_in == "4" or user_in.lower() in mainWords:
        menus.main_prompt()

    elif user_in == "5" or user_in.lower() in quitWords:
        print("Goodbye!")
        exit()
    else:
        print("That is not a valid query. Please try again.")
        menus.menu_3(ticker, ticker_info)
Exemplo n.º 2
0
def find_name():
    """ This function finds a lower case string input using .contain() method and returns all entries with string"""

    user_in = input('Please enter the search term below:\n')
    # calling rows where user_in2 found in stock_tickers['Name Lower'] and converting type series to string for retrieval
    if len(stock_tickers[stock_tickers['Name Lower'].str.contains(user_in.lower())]) > 0:
        print("\nYour search '{}' returned the following queries...\n".format(user_in))
        stock_temp = stock_tickers[stock_tickers['Name Lower'].str.contains(user_in.lower())] # temp file for printing
        # stock_temp = stock_temp.drop('Name Lower', axis=1) # removing "Name Lower" column so does not print
        # stock_temp = stock_temp.drop('Unnamed: 8', axis=1) # removing "Unnamed:  8" column so does not print
        print(stock_temp['Name'])
        get_ticker()
    else:
        print("Sorry, your search returned no queries. Please try a searching a different query.")
        menus.menu_2()
Exemplo n.º 3
0
def menu_1_choose(user_in):
    """This function processes the user selection from the main menu"""

    exploreWords = [
        '1', 'stock', 'explore', 'info', 'explore stock', 'explorestock'
    ]  # words for user input for option 1

    # checking user input and corresponding action
    if user_in.lower() in exploreWords:
        # if user selects 1 launch menu_2() function
        menus.menu_2()
    elif user_in == '2' or user_in.lower() in quitWords:
        # if user selects 3, exit app
        print('Goodbye!')
    else:
        print(
            'That is not a valid query! \nPlease try again or enter "Quit" to exit.\n'
        )
        menus.main_prompt()
Exemplo n.º 4
0
def menu_2_choose(user_choice):
    """ processing user input from search menu"""
    if user_choice.lower() in [
            '1', 'ticker', 'search ticker', 'tick', 'searchticker'
    ]:
        # open get_ticker function
        get_stock_info.get_ticker()  # if option 1, open get_tciker()
    elif user_choice.lower() in ['2', 'name', 'search name', 'searchname']:
        # open find_name function
        get_stock_info.find_name()
    elif user_choice == "3" or user_choice.lower() in backWords:
        # back to main menu
        menus.main_prompt()
    elif user_choice == "4" or user_choice.lower() in quitWords:
        # exit application
        print("Goodbye!")
        exit()
    else:
        # print in case of any other query
        print('Please enter a valid query!\n')
        menus.menu_2()
Exemplo n.º 5
0
def get_ticker():
    """this function checks if a ticker is valid and gets stock from stock_tickers dataframe"""
    ticker = input("""
To view more information about a stock please enter stock TICKER:\n(or hit RETURN to go back...)\n""")

    if len(ticker) > 0: # if some value entered for ticker (i.e. not RETURN) print ticker info
        if ticker.upper() in stock_tickers.index: # if ticker found in stock_tickers.index

            ticker_info = stock_tickers.loc[ticker.upper()] # creating temp object to store ticker info
            # dropping unwanted columns for clean printing to user
            ticker_info = ticker_info.drop('Name Lower')
            ticker_info = ticker_info.drop('Unnamed: 8')
            user_in = input("Ticker {} found. This ticker is for {}. Would you like to continue? (Y/N)".format(ticker.upper(),ticker_info[0]))

            if user_in.lower() in yesWords:  # is user selects yes
                menus.menu_3(ticker, ticker_info)

            elif user_in.lower() in noWords:  # if user selects no
                menus.menu_2()

            elif user_in.lower() in backWords:  # if user selects back
                menus.menu_2()

            elif user_in.lower() in quitWords:  # if user selects quit
                print("Goodbye!")
                exit()
            else:
                print("That is not a valid query. Please try again!")
                get_ticker()

        else:
            print('\nSorry, that ticker was not found! Please try another query, or search for a stock by name.\n')
            menus.menu_2()
    else:
        # else if RETURN entered, go back to previous menu
        menus.menu_2()