Questions tagged [buy]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
29 views

Pset9 Check50: buy handles valid purchase

I'm almost done with Finance but my solution doesn't pass the last tests of Check50. I'm stuck on the buy function. Check50 outputs the following: "buy handles valid purchase expected to find &...
  • 1
0 votes
0 answers
32 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 ...
0 votes
1 answer
50 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": ...
0 votes
1 answer
242 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 ...
0 votes
1 answer
262 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. ...
  • 14
0 votes
1 answer
634 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 ...
  • 3
0 votes
1 answer
52 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 ...
  • 1
0 votes
1 answer
382 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) ...
  • 1
0 votes
1 answer
25 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 ...
  • 7
0 votes
0 answers
83 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(): &...
0 votes
1 answer
493 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": ...
0 votes
2 answers
525 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 ...
  • 48
0 votes
2 answers
340 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 ...
0 votes
0 answers
78 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", ...
0 votes
1 answer
47 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. ...
0 votes
1 answer
280 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&...
0 votes
1 answer
2k 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....
0 votes
0 answers
52 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 ...
0 votes
1 answer
147 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,...
  • 19
0 votes
1 answer
54 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 ...
0 votes
1 answer
191 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) ...
  • 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 ...
  • 11
0 votes
1 answer
46 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 (...
  • 3
0 votes
1 answer
228 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) ...
0 votes
1 answer
376 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 ...
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 ...
0 votes
1 answer
290 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") ...
0 votes
1 answer
77 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() ...
0 votes
1 answer
137 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 ...
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 ...
0 votes
1 answer
394 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 ...
0 votes
1 answer
360 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 ...
0 votes
1 answer
119 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, ...
0 votes
1 answer
140 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 ...
  • 5
0 votes
2 answers
90 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, ...
0 votes
1 answer
121 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")) ...
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. ...
0 votes
1 answer
639 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""" ...
0 votes
1 answer
78 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 ...
  • 27
0 votes
1 answer
476 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 ...
  • 27
1 vote
1 answer
128 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 ...
1 vote
1 answer
474 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 ...
  • 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 ...
1 vote
1 answer
109 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 ...
  • 135
0 votes
1 answer
94 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 ...
0 votes
1 answer
87 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. # ...
  • 135
0 votes
1 answer
328 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 ...
  • 135
0 votes
1 answer
130 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: ...
0 votes
1 answer
115 views

cs50 pset7 finance always get an error in valid buy execution;;;;;

@app.route("/") @login_required def index(): """Show portfolio of stocks""" cash = db.execute('SELECT cash FROM users where id=:id',id=session["user_id"]) cash = cash[0]["cash"] stocks ...
0 votes
0 answers
769 views

Pset7 buy and quote do not pass check50

I ran my code through check50 and it didn't clear the following 2 checks: :( quote handles valid ticker symbol expected to find "28.00" in page, but it wasn't found :( buy handles valid purchase ...