Skip to main content
3 votes

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

I noticed that the issue lies in the line where I insert the stock symbol into the "stocks" table in the buy function. The problem is that I am passing stock["name"] instead of ...
Chris's user avatar
  • 31
2 votes
Accepted

Pset9 Finance Sell select menu

symbol is a list of dictionaries; that is what execute returns. Therefore the first result returns each dictionary in the template for symbol in symbol loop. Similarly, symbol[0]["symbol'} ...
DinoCoderSaurus's user avatar
2 votes

PSET9 / can't check until a frown turns upside down

Have a look at what your index renders if user buys 2 shares of something. I suspect it will show the price twice and not "total value for each holding". The usd function returns a string, ...
DinoCoderSaurus's user avatar
2 votes
Accepted

Lab 9: Birthdays - odd behaviour from delete button

Have you validated the HTML? (see Week 8 Lecture, starting at minute 54). The problem is identified in the spoiler, but you might want to take your generated HTML through the Direct Input tab at ...
DinoCoderSaurus's user avatar
2 votes
Accepted

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?

So my first question is, where does it come from? It's either bootstrap or the browser. check50 does not use the front end to make the API calls. Therefore any limits put on the html, while GREAT for ...
DinoCoderSaurus's user avatar
2 votes
Accepted

cs50 finance - RuntimeError: unsupported value: <function buy at 0x7f1c380cfd90>

buy in this sentence db.execute("INSERT INTO transactions(user_id, name, shares, price, type, symbol) VALUES(?, ?, ?, ?, ?, ?,)",user_id, item_name, shares, item_price, buy, symbol) refers ...
DinoCoderSaurus's user avatar
2 votes
Accepted

PSET9 Finance - Lookup function returns 402

It appears that iex has changed their offerings and the new 'free trial' keys do not give access to the stocks via our lookup function. We are investigating a new method, but in the meantime, this ...
curiouskiwi's user avatar
  • 18.7k
2 votes

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

Solved it thanks to some advice from CS50 discord, When you use the lookup function it returns: "name" "price" "symbol" When I stored a transaction in my database is was ...
Seth 's user avatar
  • 31
2 votes
Accepted

Check50 marks my "Quote" as if not functioning properly despite looking identical to the staffs solution

If the price is "even dollars" (ie no cents) like 28.00, quoted.html will display as $28.0. Consider using usd to transform price, either in the buy function or quoted.html.
DinoCoderSaurus's user avatar
2 votes

Week 9 - Finance - Foreign Key Mismatch

It's not what you think. The body of a try block should contain the least amount of code to catch an error. This routine should have one try/except block for each of the executes (and only the execute ...
DinoCoderSaurus's user avatar
2 votes
Accepted

What to do when IEX cloud API stopped their free trial

From the spec If you used wget to download finance.zip before Wednesday, April 10, 2024 at 8:30 AM EDT, be sure to copy, paste, and run this command inside of your finance directory in order to ...
DinoCoderSaurus's user avatar
1 vote
Accepted

CS50 Problem set 9 - Finance - RuntimeError: foreign key mismatch - "holdings" referencing "users"

First question: Did you confirm that the userid in the insert statement for the row you're trying to insert into the holdings table actually exists in the userid table? If not, you get a runtime ...
Cliff B's user avatar
  • 69.1k
1 vote
Accepted

CS50 Finance: Can't add time of transaction

I think you've conflated two different concepts here. First, understand that ALTER TABLE changes the entire table,not just a single row. Don't use that to update an individual record. Next, you can ...
Cliff B's user avatar
  • 69.1k
1 vote

PSET9 finance 'buy handles valid purchase error, expected to find "112.00" in page, but it wasn't found'

I have answer and I was going to paste just a link, but stack overflow is not allowing me to paste link or post answer if my message is not at least 30 characters. That is why you can see this message....
fazliddin fayziev's user avatar
1 vote
Accepted

PSET9 FINANCE SQLITE "no such column exists" while multiplying two columns to update a third

SQLite (or any other flavor of SQL) does not allow using column aliases in the same SELECT query.
DinoCoderSaurus's user avatar
1 vote

PSET 9: C$50 Finance. Why not <input type="number"> instead of text?

As you probably have already learned, problems must conform to the spec, full stop. I totally agree that the input should be validated in the HTML; it is better UI/UX. You could always run check50 to ...
DinoCoderSaurus's user avatar
1 vote
Accepted

For finance, does anyone know why my page for selling stocks does not work?

Assume it is this line that produces error: quantity_owned = int((db.execute ("SELECT quantity FROM user_stocks WHERE user_id = ?"), session['user_id'])[0]) There is a ) in the wrong place. ...
DinoCoderSaurus's user avatar
1 vote
Accepted

For finance, does anyone know why my page to buy stocks does not work?

I'm new to this, but am working on this PSET myself at the moment. Here's what I think the problem is (feel free to roast me if it's not! ;)): lookup returns a dictionary with 3 keys: 1.) name 2.) ...
cormacl's user avatar
  • 48
1 vote
Accepted

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

The error is on compras.id, which implies it is defined as UNIQUE. (Perhaps edit the compras schema into the question). The INSERT into compras is setting id to user_id, which would allow one purchase ...
DinoCoderSaurus's user avatar
1 vote
Accepted

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

While it is arguably better UI/UX to validate the input in the html, it does not fulfill the requirements of the buy spec: Require that a user input a number of shares, implemented as a text field ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Why does my lookup function keep returning "None"?

Since the quote spec calls for an element named "symbol", and this if not request.form.get("stock"): is apparently working, it looks like the element is not named properly in the ...
DinoCoderSaurus's user avatar
1 vote
Accepted

I'm on pset9 right now and I'm running check50 on my code and getting :( logging in as registered user succeeds expected status code 200, but got 403

This hash = generate_password_hash("password") is a problem. It is hashing the string literal "password". (Try to login using "password" as the password; it should work). ...
DinoCoderSaurus's user avatar
1 vote

check50 errors for "buy" and "sell"

If the symbol entered is invalid, this line price = search["price"] gives error "TypeError: 'NoneType' object is not subscriptable" because lookup returns None. Code will give ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset 9 Finance index function, current stock price not displaying correctly

The problem isn't lookup. The problem is portfolio. There are exactly two keys in the portfolio dictionary, "current_price" and "holding_total". They are set to the values in each ...
DinoCoderSaurus's user avatar
1 vote

check50 on finance pset

It is much better UI/UX to add the constraints to the front end. Alas, check50 is verifying that the code performs as instructed in the spec. The same directive is given for buy and sell routes. From ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset9 Finance - How do I load the symbol into my input box on the Buy.html?

Add value = "{{ stocks }}" to the symbol input element in buy.html. There are some problems in the GET branch of the buy route: To retrieve values from a GET request, use request.args ...
DinoCoderSaurus's user avatar
1 vote
Accepted

How to access the values returned by SELECT SUM

The problem is the double double-quotes. The first phrase is: "SELECT SUM(size) AS " the second phrase is: " FROM history WHERE id = ? AND symbol = ?" and Total is in no-man's land....
DinoCoderSaurus's user avatar
1 vote
Accepted

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

You are iterating over a variable called holdings: {% for stock_holdings in holdings %} But you are not passing any such variable to the template: return render_template("index.html", ...
curiouskiwi's user avatar
  • 18.7k
1 vote
Accepted

Runtime Error Unsupported Value in pset9 Finance

From the doc for execute in CS50 Library for Python Returns for SELECT, a list of dict objects, each of which represents a row in the result set The argument to the INSERT query needs to be a ...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset9 buy function // buy handles invalid ticker symbol and handles valid purchase having error

Quote and stocks are one and the same. So you should keep only one of them. Your first error takes place at price = quote.get("price"). This line is correct but in the wrong place. Once you ...
Vsjain's user avatar
  • 1,016

Only top scored, non community-wiki answers of a minimum length are eligible