Questions tagged [buy]
The buy tag has no usage guidance.
99
questions
1
vote
1
answer
538
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: ...
0
votes
2
answers
67
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 ...
0
votes
0
answers
91
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 &...
0
votes
0
answers
161
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
90
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
360
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
343
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. ...
0
votes
1
answer
852
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 ...
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 ...
0
votes
1
answer
526
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)
...
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 ...
0
votes
0
answers
107
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
602
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
636
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 ...
0
votes
2
answers
367
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
82
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
49
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
304
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
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....
0
votes
0
answers
53
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
165
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,...
0
votes
1
answer
57
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
197
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) ...
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 ...
0
votes
1
answer
47
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 (...
0
votes
1
answer
243
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
443
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
340
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
83
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
156
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
614
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
378
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
123
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
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 ...
0
votes
2
answers
92
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
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"))
...
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
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"""
...
0
votes
1
answer
81
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 ...
0
votes
1
answer
484
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 ...
1
vote
1
answer
133
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
497
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 ...
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
112
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 ...
0
votes
1
answer
95
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
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.
# ...
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 ...
0
votes
1
answer
131
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:
...