Just recently, on my implementation of CS50 Finance, I bought 4 shares of Netflix, and then another 2, but instead of showing 6 shares on the Portfolio, it's only showing 2.  The "Total" value for the shares is also current price of NFLX * 2.

I'll show you guys my index route and template code just in case.  Route: https://pastebin.com/Gw64H1ky; template: https://pastebin.com/macgJ9AE.

What could the problem be? I think it's in index itself, either in the route or in the template. Might be a problem in the no_of_shares_dict dictionary, but I'm not sure how I can check to make sure.

1 Answer 1


It's more likely that the problem lies in the code that is updating the portfolio table when a stock is purchased. Based on what little was stated in the question, it sounds like it is replacing the existing row in the database for the user and stock symbol instead of updating the quantity. It's also possible that it is just inserting another row for the buy and only processing one row when displaying the portfolio.

Without seeing the buy code, that's about all I can guess.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .