예제 #1
0
def lookup():
    if request.method == 'GET':
        return render_template('lookup.html')
    else:
        company_name = request.form['coname']
        x = model.lookup(company_name)
        return render_template('lookup.html', message=x)
예제 #2
0
def lookup(balance, earnings, idno, xbal, xearn):
    if request.method == 'GET':
        return render_template('lookup.html',
                               balance=balance,
                               earnings=earnings,
                               idno=idno,
                               xbal=xbal,
                               xearn=xearn)
    else:
        idz1 = idno
        companyname = request.form['company1']
        x = model.lookup(companyname)
        zeez = x.split()
        if "Sorry," in zeez:
            message2 = "An error occured..." + x
            return render_template('lookup.html',
                                   balance=balance,
                                   earnings=earnings,
                                   idno=idno,
                                   xbal=xbal,
                                   xearn=xearn,
                                   message2=message2)
        else:

            bal, earn = model.create(idz1)
            mess = "your ticker is...." + x
            return redirect(
                url_for("landing",
                        message1=mess,
                        balance=bal.balancez,
                        earnings=earn.earningz,
                        idno=idno,
                        xbal=bal,
                        xearn=earn))
예제 #3
0
def take_action(locations: Dict[str, str], args: Namespace) -> GoAction:
    if args.new:
        return Update(m.new(locations, args.new.name, args.new.path))
    elif args.delete:
        return Update(m.delete(locations, args.delete))
    elif args.rename:
        return Update(m.rename(locations, args.rename.old_name, args.rename.new_name))
    elif args.copy:
        return Update(m.copy(locations, args.copy.old_name, args.copy.new_name))
    elif args.name is None:
        return Display("Available locations:", locations, 0)
    else:
        p = m.lookup(locations, args.name)
        if isinstance(p, str):
            return Navigate(expand(p))
        elif isinstance(p, m.NoMatchError):
            return Display(
                f"Couldn’t find {args.name} – available locations are:",
                locations,
                1
            )
        elif isinstance(p, m.AmbiguousPrefixError):
            if args.name in p.matches:
                return Navigate(expand(p.matches[args.name]))
            else:
                return Display(
                    f"Got more than one match for {args.name}:",
                    p.matches,
                    2
                )
        else:
            return Display("Got an unknown error.", {}, 3)
예제 #4
0
def lookup():
    balance = model.check_balance()
    if request.method == 'GET':
        return render_template('lookup.html', balance=balance)
    else:
        company_name = request.form['company_name']
        x = model.lookup(company_name)
        return render_template('homepage.html', x=x, balance=balance)
예제 #5
0
def game_loop():
    user_input = view.main_menu()
    buy_inputs = ['b', 'buy']
    sell_inputs = ['s', 'sell']
    lookup_inputs = ['l', 'lookup']
    quote_inputs = ['q', 'quote']
    exit_inputs = ['e', 'exit']
    view_inputs = ['v', 'view']
    pl_inputs = ['p', 'p']
    acceptable_inputs = buy_inputs      \
        + sell_inputs   \
        + lookup_inputs \
        + quote_inputs  \
        + exit_inputs   \
        + view_inputs   \
        + pl_inputs
    on_off_switch = True
    while on_off_switch:
        if user_input.lower() in acceptable_inputs:
            if user_input.lower() in buy_inputs:
                (ticker_symbol, trade_volume) = view.buy_menu()
                x = model.buy(ticker_symbol, trade_volume)
                return x

            elif user_input.lower() in sell_inputs:
                (ticker_symbol, trade_volume) = view.sell_menu()
                x = model.sell(ticker_symbol, trade_volume)
                return x

            elif user_input.lower() in lookup_inputs:
                company_name = view.lookup_menu()
                x = model.lookup(company_name)
                return x

            elif user_input.lower() in quote_inputs:
                ticker_symbol = view.quote_menu()
                x = model.quote(ticker_symbol)
                return x

            elif user_input.lower() in view_inputs:
                balance = view.portfolio_menu()
                x = model.portfolio(balance)
                return x

            elif user_input.lower() in pl_inputs:
                p = view.pl_menu()
                x = model.pl(p)
                return x

            elif user_input.lower() in exit_inputs:
                break
                #on_off_switch = False
            else:
                print('Bad input. Restarting game in five seconds...')
                time.sleep(5)
                game_loop()
        else:
            return 'Plese Start Over'
예제 #6
0
def lookup():
    if request.method == 'GET':
        message = 'What do you wanna to look up {}?'.format(
            session['username'])
        return render_template('lookup.html', message=message)
    elif request.method == 'POST':
        ticker = request.form["ticker"]
        message = model.lookup(ticker)
        return render_template('lookup.html', message=message)
예제 #7
0
def get_lookup(apikey):
    if not request.json or not 'Company' in request.json:
        abort(400)
    if not isinstance(request.json['Company'], (str)):
        abort(400)

    user_name = model.api_authenticate(apikey)
    if not user_name:
        return (jsonify({"error": "count not authenticate"}))

    company = request.json['Company']
    return jsonify({"Ticker": model.lookup(company)})
예제 #8
0
파일: login.py 프로젝트: ccohane/WebTrader
def lookup():
    if request.method == 'GET':
        return render_template('dashboard.html')
    else:
        user_name = '%s' % escape(session['username'])
        info = model.dashboard(user_name)
        company = request.form['lookup']
        ticker = model.lookup(company)
        if ticker:
            return render_template('dashboard.html',
                                   lookup_info=company + ': ' + ticker,
                                   info=info)
        else:

            return render_template('dashboard.html',
                                   lookup_info='Could not find Ticker for ' +
                                   company,
                                   info=info)
예제 #9
0
def hompepage():
    if request.method == 'GET':
        message = 'Welcome to web trader, time to make some $$'
        return render_template('homepage.html', message=message)
    elif request.method == 'POST':
        look_up = request.form["look_up"]
        ticker = request.form["ticker"]
        trade_volume = request.form["quantity"]
        if look_up:
            message = model.lookup(look_up)
            return render_template('homepage.html', message=message)
        elif trade_volume:
            model.buy(session['username'], ticker, trade_volume)
            message = "Congratulations you have purchased stuff"
            return render_template('homepage.html', message=message)
        else:
            message = "Come again?"
            return render_template('homepage.html', message=message)
예제 #10
0
def game_loop():
    user_input = view.main_menu()
    lookup_inputs = ['l', 'lookup', 'look-up', 'lookup']
    quote_inputs = ['q', 'quote']
    acceptable_inputs = lookup_inputs \
          +quote_inputs
    if user_input in acceptable_inputs:
        if user_input in lookup_inputs:
            x = view.lookup_menu()
            y = model.lookup(x)
            print(y)
        elif user_input in quote_inputs:
            x = view.quote_menu()
            y = model.quote(x)
            print(y)
        else:
            print('Error: uncaught exception')
    else:
        print('Error: uncaught exception')
예제 #11
0
파일: app.py 프로젝트: sienatime/ocr-jpn
def define():
    lookup = request.args.get("lookup")

    db = model.lookup(lookup)

    return db
예제 #12
0
def game_loop():
    start = view.start_up_menu()
    if start == "s":
        (user_name, password) = view.sign_up_menu()
        model.sign_up(user_name, password)
    else:
        (user_name, password) = view.logg_in_menu()
        _id = model.user_check(password)
        print(_id)

    while 1:
        buy_inputs = ['b', 'buy']
        sell_inputs = ['s', 'sell']
        lookup_inputs = ['l', 'lookup', 'look up', 'look-up']
        quote_inputs = ['q', 'quote']
        exit_inputs = ['e', 'exit', 'quit']
        view_inputs = ['v']
        acceptable_inputs = buy_inputs     \
                            +sell_inputs   \
                            +lookup_inputs \
                            +quote_inputs  \
                            +exit_inputs   \
                            +view_inputs
        user_input = view.main_menu()
        if user_input in acceptable_inputs:
            if user_input in buy_inputs:
                balance = model.check_balance(user_name)
                fee = 6.25
                ticker_symbol = view.quote_menu()
                price = model.quote(ticker_symbol)
                trade_volume = view.transaction_menu(balance, ticker_symbol,
                                                     price)
                transaction_cost = (float(trade_volume) * price) + fee
                if transaction_cost <= balance:
                    balance -= transaction_cost
                    model.update_cash(user_name, balance)
                    model.buy(user_name, ticker_symbol, float(trade_volume),
                              float(price))
                    model.buy_holdings(user_name, ticker_symbol,
                                       float(trade_volume), price)
                else:
                    print("Not enough monay")

            elif user_input in sell_inputs:
                ticker_symbol = view.quote_menu()
                price = model.quote(ticker_symbol)
                trade_volume = view.sell_menu()
                owned = model.check_holdings(user_name, ticker_symbol)
                if owned and int(trade_volume) <= owned:
                    model.sell_holdings(user_name, ticker_symbol, trade_volume,
                                        price, owned)

            elif user_input in lookup_inputs:
                return model.lookup(view.lookup_menu())
            elif user_input in quote_inputs:
                return model.quote(view.quote_menu())
            elif user_input in view_inputs:
                users = model.get_users()
                users_list = [
                ]  # this is a list of all the users that currenttly have holdings
                for i in users:
                    users_list.append(i[0])

                users_holdings = [
                ]  # users holdings by tickers but not numbers
                for i in users_list:
                    user_holdings = model.get_holdings(i)
                    a = []
                    for i in user_holdings:
                        a.append(i[0])
                    users_holdings.append(a)

                tickers = [
                ]  # is all the stocks the users, un "set'd" and joinined together
                for i in users_holdings:
                    for j in i:
                        tickers.append(j)
                prices = {
                }  # this has all the prices for all the stocks owned in the holdings
                for i in set(tickers):  #
                    price = model.quote(i)
                    prices[i] = price

                volumes = [
                ]  # a list of lists of amount of stock each of them own
                for i in users_list:
                    volumes.append(model.holdings_volumes(i))
                # print(users_holdings)
                # print(volumes)
                values_final = {}
                for i in range(len(users_holdings)):
                    total = 0
                    for j in range(len(users_holdings[i])):
                        total += (prices[users_holdings[i][j]]) * (
                            volumes[i][j][0])
                    values_final[users_list[i]] = total
                highest = 0
                sorted_words = {}
                while values_final:
                    for i in values_final:
                        if values_final[i] >= highest:
                            highest = values_final[i]
                            word = i
                    sorted_words[word] = highest
                    values_final.pop(i)
                    highest = 0
                for i in sorted_words:
                    print("{} : {}".format(i, sorted_words[i]))
                    # highest = 0
                # while values_final:
                #     for i in range(len(values))
                #     if values[i]

                # need to add total balance
                #work vwamp

            elif user_input in exit_inputs:
                break
예제 #13
0
파일: app.py 프로젝트: sienatime/ocr-jpn
def define():
    lookup = request.args.get("lookup")

    db = model.lookup(lookup)

    return db