Skip to main content

Questions tagged [buy]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
102 views

Stuck on Problem Set 9 with error buy handles valid purchase expected to find "112.00" in page, but it wasn't found

Been trying to troubleshoot this error with help from the internet but I have been unable to do so. Below is my app.py: import datetime from cs50 import SQL from flask import Flask, flash, redirect, ...
zekaistic's user avatar
1 vote
1 answer
1k views

CS50 Finance (week 9 problem set) Check 50 Fails despite program working fine, please help

My program works perfectly when I test it on my own, but when I run check50 it encounters an issue with the "buy" page. The error is """exception raised in application: ...
Seth 's user avatar
  • 31
0 votes
2 answers
109 views

TypeError: 'NoneType' object is not subscriptable in PSET9, but working manually

I am working on pset9 Finance. I have implemented the functionality for purchasing stocks, and it works well when I manually test it. However, when I run the CS50's check50 validation, it returns an ...
Chris's user avatar
  • 31
0 votes
0 answers
196 views

Pset 9 Finance 'TypeError: 'NoneType' object is not subscriptable'

I'm currently doing Finance, for CS50x 2023, but I keep getting the same 'nonetype' object is not subscriptable error. I have tried to debug the error and found out that it is the user_id variable ...
Jonathan's user avatar
0 votes
1 answer
110 views

CS50 PS9 finance :( buy exception raised in application: TypeError: '<' not supported between instances of 'str' and 'float'

@app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): """Buy shares of stock""" if request.method == "GET": ...
Karl Kuehn's user avatar
0 votes
1 answer
400 views

ValueError: UNIQUE constraint failed: on finance pset9, could someone point me in the right direction on which values should be UNIQUE from my table?

Could someone help me figure out which values should I define as UNIQUE? I'm getting the ValueError: UNIQUE constraint failed: compras.id beacuase of the way I created my table for keeping tab of who ...
Roger Roger's user avatar
0 votes
1 answer
376 views

Check50 says buy allows fractional, negative numbers but it doesn't. Where am I going wrong?

I'm down to my last check50 frown (:( buy handles fractional, negative, and non-numeric shares expected status code 400, but got 200) but my code doesn't allow for these, so I don't know what to do. ...
Lperino's user avatar
  • 14
0 votes
1 answer
930 views

CS50 Finance index doesn't display what it needs to

I'm at the last check for the 'buy' part and I keep getting: :( buy handles valid purchase expected to find "9,888.00" in page, but it wasn't found I'm pretty sure that number is supposed to ...
Fijn's user avatar
  • 3
0 votes
1 answer
57 views

Buy/Sell on Index - button attributes & form value issues

I've got a couple issues adding my own buy/sell buttons to the index page. First, each "Buy" or "Sell" buttons opens up the form for all of the table rows. How can I modify these ...
zawave's user avatar
  • 1
0 votes
1 answer
580 views

PS9 Finance - Check50 - :( buy handles valid purchase

I am running into an issue with check50 on my buy function. Check50 gives me the following error: :( buy handles valid purchase Cause application raised an exception (see the log for more details) ...
alou64's user avatar
  • 1
0 votes
1 answer
28 views

Why is the portfolio not being displayed? I get not errors but nothing is being displayed. I am at a loss as to why I cannot display any stocks

@app.route("/") @login_required def index(): """Show portfolio of stocks""" rows = db.execute("SELECT symbol, SUM(shares) as Total_shares FROM ...
Drey''s user avatar
  • 7
0 votes
0 answers
113 views

issue with my "Buy" code in finance problem set

There is a syntax error when I try to insert the buy information into my trade table. Here is my code. The issue is at the long db.execute line. Any guidance would be great. Thanks. def buy(): &...
JerryCinc's user avatar
0 votes
1 answer
649 views

pset9 Finance - " RuntimeError: unsupported value: " error

(1) "buy" code in application.py: @app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): if request.method == "GET": ...
starbvuks's user avatar
0 votes
2 answers
684 views

PSET9 Finance: Check50 says Buy doesn't handle fractional/invalid shares, but when I try these things my page does reject them. Why check50 no like?

I have been using some of the html from the cs50 finance example page: https://finance.cs50.net/buy (which is permitted by CS50) I think it may be at the root of the problem. Here's the relevant html ...
cormacl's user avatar
  • 48
0 votes
2 answers
375 views

CS50 pset8 finance buy

I have been struggling with the buy portion of the finance assignment for CS50. I have created my new tables and written down the logic concerning buying stocks. When I run flask and try to purchase ...
rutgerv's user avatar
0 votes
0 answers
83 views

Finance - Buy Implementation

I am getting the error message "500 Internal Server Error" when trying to buy shares. Can you please tell me what I am missing? The application.py code is: @app.route("/buy", ...
Leonidas Smiley's user avatar
0 votes
1 answer
50 views

Week 8 - Finance - Buy - Getting Error Message Missing Shares

I'm trying to get the Buy implementation to work but I keep on getting the error message "Missing Shares" when I log into the cs50 finance site and enter in the symbol and number of shares. ...
Leonidas Smiley's user avatar
0 votes
1 answer
309 views

PSET8 Finance Buy

For some reason, my buy function will not work. When I try to "buy" a share of stock, it always goes to internal server error. Here is my code: def buy(): if request.method == "POST&...
leesquared's user avatar
0 votes
1 answer
3k views

The view function did not return a valid response. The function either returned None or ended without a return statement

I can't figure out what is wrong in my code My python code: def buy(): """Buy shares of stock""" if request.method == "GET": render_template("buy....
Luana Nunes's user avatar
0 votes
0 answers
54 views

Finance CS50 Buy Function - Sufficient Cash check not working

I've been stuck on buy function for PSET8 Finance for a long time now. I'm stumbling at the very beginning and can't seem to proceed further. The code error checks for incorrect or no inputs in the ...
hrithikbansal's user avatar
0 votes
1 answer
171 views

cs50 Finance Runtime error FOREIGN KEY constraint failed

I'm working on pset8 cs50 finance and I'm encountering a runtime error with buy. I've gotten both register and quote to work without issue so I've tried comparing my code to check for incorrect syntax,...
Renée's user avatar
  • 19
0 votes
1 answer
59 views

C$50 FINANCE- BUY ERROR

I have a problem with my code on buy. I was wondering if anyone can help me identify the error. Whenever I go to the buy and enter the symbol and shares and click buy, it shows a 500 Internal Server ...
jankendrick's user avatar
0 votes
1 answer
198 views

Finance: Can not Update and Insert to SQL

In my buy function I cant INSERT or UPDATE data in SQL. RuntimeError: (sqlite3.OperationalError) near "ON": syntax error [SQL: INSERT INTO buy (share_name, share_symbol, share_price, shares, id) ...
Tory's user avatar
  • 1
0 votes
1 answer
1k views

C$50 Finance Buy and Quote not working

When I test my code myself, it seems to work, but check50 is showing otherwise. Quote has a single problem, and buy has two problems, but I am not able to figure out where in the code is the error and ...
AK2150's user avatar
  • 11
0 votes
1 answer
48 views

CS50 Finance pset8 KeyError on /buy of application.py

I am having real trouble solving the issue I have with the /buy section of the task. I keep getting struck with an issue on the following section of code: db.execute("INSERT INTO transactions (...
akezd's user avatar
  • 3
0 votes
1 answer
245 views

pset8 c$50 finance /buy - transactions RuntimeError: (sqlite3.OperationalError) near "''": syntax error

I'm stuck on pset8 c$50 finance /buy: Form validation works properly but when i try to execute the INSERT INTO transactions table i get the following error: RuntimeError: (sqlite3.OperationalError) ...
Ron Braha's user avatar
0 votes
1 answer
464 views

pset 8 finance: ":( buy handles valid purchase" fails

I`am bug fixing my application and can't find a solution for the ":( buy handles valid purchase" test. Here is Log: expected to find "112.00" in page, but it wasn't found Log sending POST ...
Dawienchi's user avatar
0 votes
1 answer
44 views

I am having trouble correctly rendering bought.html Can someone help? More details below

I am getting an bug in my code. This is caused by From the ide DEBUG:cs50:SELECT id FROM stock_info where id = 108 length of rows {} 1 DEBUG:cs50:SELECT * FROM stock_info where id = 108 length of ...
grggthwrth's user avatar
0 votes
1 answer
372 views

Getting an error in my code. Can someone help? My main question is can a select statement return an empty list without having an error?

Here is the code @app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): """Buy shares of stock""" if request.method == "POST": stock = request.form.get("symbol") ...
grggthwrth's user avatar
0 votes
1 answer
86 views

Getting an error in buy function. Don't know how to fix it. Can someone help? More detail below

Buy function @app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): """Buy shares of stock""" if request.method == "POST": stock = request.form.get("symbol").upper() ...
grggthwrth's user avatar
0 votes
1 answer
162 views

How do I get id for the buy function? I am pretty sure I am doing the correct code but still getting an error. Can someone help?

I am trying to get the code to work and am not worrying about sql injections yet. Code from Buy function current_cash = db.execute("SELECT cash FROM users WHERE id=current_id") I asked a similar ...
grggthwrth's user avatar
0 votes
1 answer
48 views

pset8 finance portfolio on new stock/id

I'm trying to make it so when the user doesn't already own the stock, it adds it to the table. If they do already own it, it should update. The problem is when I try it, it buys 2x what it is supposed ...
Joel Banks's user avatar
0 votes
1 answer
767 views

pset7/ finance.py error: :( buy handles valid purchase application raised an exception (see log for details)

I keep having the same error ":( buy handles valid purchase application raised an exception (see log for details)" for days now and I don't have any clue what I should modify in my code to pass the ...
Rinus van Grunsven's user avatar
0 votes
1 answer
385 views

PSET7 Finance- Quote and Buy not passing all checks

I've just come back to CS50 after the semester ended and have been trying to debug my program to no avail. The application appears to be working when I test it myself, passes all checks, but has ...
Billy Currie's user avatar
0 votes
1 answer
124 views

Pset7 Finance Key Error in Buy

I have some trouble with the insertion into the database table in the buy section. I get a KeyError: "id". This is my code: result = db.execute("INSERT INTO transactions (id, symbol, price, shares, ...
viet 's user avatar
0 votes
1 answer
143 views

PSET7 - Finance buy - can't buy stock as user is logged out

I'm on the buy section of pset7's finance. I can submit a quote and get the correct information back. However, when I go to the buy page and try to purchase said stock, I get a 403 error code that I ...
MEM's user avatar
  • 5
0 votes
2 answers
93 views

Pset7 buy portfolio values are null

Pset7 buy. Debug is super clear but I still don’t understand why it doesn’t work: DEBUG:cs50:SELECT cash FROM users WHERE id = 1 DEBUG:cs50:INSERT INTO portfolio (stock, shares, balance) VALUES(NULL, ...
IrinaPenzina's user avatar
0 votes
1 answer
124 views

What's the error?-PSET7/buy

@app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): """Buy shares of stock""" if request.method == "POST": symbol_lookup=lookup(request.form.get("symbol")) ...
user22430's user avatar
0 votes
1 answer
2k views

PSET7 Finance Buy

This is my code so far. It works. Now I am at the stage where you need to check and see if user already has that same stock. If the user has it, I have to add it, if not, just insert it to the table. ...
sksch1663's user avatar
0 votes
1 answer
640 views

Finance: Buy AttributeError: 'TypeError' object has no attribute 'name'

I have been trying to debug this for the past three hours but I can't find anything to save my life @app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): """Buy shares of stock""" ...
albaniandude's user avatar
0 votes
1 answer
84 views

Pset7 finance, after I run buy function, portfolio table updated check 50 fails and I get 404 error

after I run check 50, everything shows green except these: I am trying to fix the error for buy. After I run flask and tried to make purchase, it shows 404 however my portfolio table get updated. So ...
Issa's user avatar
  • 27
0 votes
1 answer
487 views

pset7 finance portfolio table won't update with buy function

Below is my code for buy. After I run flask and tried to make a purchase, the history table updated and cash deducted from users table. However, portfolio table is still empty. I am thinking the error ...
Issa's user avatar
  • 27
1 vote
1 answer
136 views

Portfolio not updating in SQLite, Problem Set 7, Buy

I've been having an issue in PSET7 buy where I am prompted with an error whenever I attempt to update my portfolio. Cash is deducted from the users total, but there is no new table containing the ...
Billy Currie's user avatar
1 vote
1 answer
505 views

cs50 pset7 buy syntax error

i cannot see any syntax error for several days, so if anything can help is highly appropriated here is my code : @app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): """Buy ...
Yao Lu's user avatar
  • 15
0 votes
1 answer
132 views

pset7 buy function stopped working... not inserting to portfolio

My buy function was working when I tested it, buy yesterday, when I was testing my implementation of "index" it stopped. The "INSERT INTO portfolio" line is no longer executing properly, and I cannot ...
user3256's user avatar
1 vote
1 answer
113 views

Pset7 Finance Unable to Buy Multiple Shares

I am able to make 1 purchase which appears on my index page, however if I try buy any further stocks my cash goes down but the stocks are not shown and aren't inserted into my portfolio. Here is my ...
M. Alex's user avatar
  • 135
0 votes
1 answer
96 views

can someone please help me with why I am getting internal server error after I enter the symbol and no. and click on buy ?pset7

File "/home/ubuntu/workspace/pset7/finance/helpers.py", line 34, in decorated_function return f(*args, **kwargs) File "/home/ubuntu/workspace/pset7/finance/application.py", line 143, in buy ...
user21692's user avatar
0 votes
1 answer
88 views

Pset7 Finance Buy Runtime Error - Date

When I try to update the users portfolio I receive a runtime error from passing in 'when' as date('now'). Please can someone tell what I should be doing. Here is part of my buy function code. # ...
M. Alex's user avatar
  • 135
0 votes
1 answer
329 views

Pset7 Finance Buy Function Internal Server Error

When I try to insert the portfolio values into the SQL database I receive an internal server error, please can someone tell me what I'm doing wrong. if request.method == "POST": # ensure symbol ...
M. Alex's user avatar
  • 135
0 votes
1 answer
132 views

Buy causes internal server error

def buy(): """Buy shares of stock""" if request.method == "POST": shares = float(request.form.get("shares")) stock = lookup(request.form.get("symbol")) if not stock: ...
Joel Banks's user avatar