Questions tagged [buy]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
62 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 ...
user avatar
0 votes
1 answer
65 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. ...
user avatar
  • 14
0 votes
0 answers
33 views

CS50X Finance: check50 says buy isn't handling valid purchase. But it is handling fine

I'm wondering what is being tested because its looking for the value 112. expected to find "112.00" in page, but it wasn't found I'm flashing the result of the buy transaction on the index....
user avatar
0 votes
1 answer
128 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 ...
user avatar
  • 3
0 votes
1 answer
43 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 ...
user avatar
  • 1
0 votes
1 answer
126 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) ...
user avatar
  • 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 ...
user avatar
  • 7
0 votes
0 answers
37 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(): &...
user avatar
0 votes
1 answer
255 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": ...
user avatar
0 votes
2 answers
250 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 ...
user avatar
  • 38
0 votes
2 answers
267 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 ...
user avatar
0 votes
0 answers
68 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", ...
user avatar
0 votes
1 answer
43 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. ...
user avatar
0 votes
1 answer
224 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&...
user avatar
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....
user avatar
0 votes
0 answers
42 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 ...
user avatar
0 votes
1 answer
127 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,...
user avatar
  • 19
0 votes
1 answer
47 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 ...
user avatar
0 votes
1 answer
179 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) ...
user avatar
  • 1
0 votes
1 answer
883 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 ...
user avatar
  • 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 (...
user avatar
  • 3
0 votes
1 answer
200 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) ...
user avatar
0 votes
1 answer
287 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 ...
user avatar
0 votes
1 answer
43 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 ...
user avatar
0 votes
1 answer
211 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") ...
user avatar
0 votes
1 answer
58 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() ...
user avatar
0 votes
1 answer
98 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 ...
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 ...
user avatar
0 votes
1 answer
222 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 ...
user avatar
0 votes
1 answer
346 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 ...
user avatar
0 votes
1 answer
100 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, ...
user avatar
0 votes
1 answer
126 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 ...
user avatar
  • 5
0 votes
2 answers
87 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, ...
user avatar
0 votes
1 answer
118 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")) ...
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. ...
user avatar
0 votes
1 answer
638 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""" ...
user avatar
0 votes
1 answer
74 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 ...
user avatar
  • 27
0 votes
1 answer
468 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 ...
user avatar
  • 27
1 vote
1 answer
121 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 ...
user avatar
1 vote
1 answer
429 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 ...
user avatar
  • 15
0 votes
1 answer
131 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 ...
user avatar
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 ...
user avatar
  • 135
0 votes
1 answer
89 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 ...
user avatar
0 votes
1 answer
86 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. # ...
user avatar
  • 135
0 votes
1 answer
324 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 ...
user avatar
  • 135
0 votes
1 answer
122 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: ...
user avatar
0 votes
1 answer
110 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 ...
user avatar
0 votes
0 answers
729 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 ...
user avatar
0 votes
1 answer
193 views

Pset7 - buy updates shares in portfolio but not cash in users

My portfolio table tracks correctly the number of shares bought, however I encounter issues when I also try to update the cash that's left after this "purchase" in the users table. I have defined the ...
user avatar
  • 31
1 vote
1 answer
391 views

issues with buy - functionality works but fails check50

Can't figure this out. My code passes functionality it buys stocks no problem but fails check50 with this error: :( buy handles valid purchase application raised an exception (see log for details) ...
user avatar