CS50 Finance | CS 50 Week 9 Problem Set Finance | Beginners Guide to PSET 9 2024
Vložit
- čas přidán 7. 09. 2024
- 00:00 Intro, 01:48 Register, 06:11 Quote, 07:47 Buy, 10:35 SQL Update, 12:22 Index, 15:58 Sell, 19:07 History
Welcome to This is CS50 Week 9 Problem Set - Finance. This tutorial will cover how to complete CS50x Finance.
Don't forget to export API_KEY=value where "value" is your exact APK key starting with pk_. this is run from terminal $.
Then cd finance. You'll need 'flask run' and Ctrl+C will stop flask from running.
sqlite3 finance.db to alter SQL and .exit to return to /finance then back in to flask run.
Happy Watching!
NOTE! - to PASS the CS50 check, you NEED to implement the logic I left out in the def index portion of the app.py - you MUST have shares and totals down to two decimal points to clear the check. You may want to use the 'usd' function and or some 'float' logic. There are also other ways to solve this. Good Luck!
Critical UPDATE: The BUY function EXPLICITLY wants a "button" despite the form being in working order, you need to update the code as follows on buy.html (this is a modification only to the last line that turns the from click into a button to satisfy:
Buy
Shares:
Symbol:
Submit
The issue with buttons actually now applies to all buttons in Buy, sell and quote.
Just use for every button or check50 will turn red (tested in 2024)
Crucial here is the type="submit", which the html seems to be tested/scanned for.
@@lpdemodimi I love this quote - I haven't gotten the update for 2024 yet so THANK YOU for noting this!
@@lpdemodimi hey I've done this but it's still showing me "expected button to submit form, but none was found."
:( buy handles valid purchase
expected to find "112.00" in page, but it wasn't found
I'm having this problem even though I got the right text to appear in a flash message and the button to work.
@@chaitanyadubakula same, even im getting it. did u figure out how to solve it?
People having issues with the 2024 version,: there is a note for the index. The lookup function no longer returns a "name". Just delete ( stock["name"] = quote["name"]) from the code and also from the html table. Thanks Devin for all your great tutorials.
I love this comment! I Hope everyone is reading this. thank you!!!
I do not understand how it should be now implemented. Can you please help?
My previous code was like this:
for stock in stocks:
quote = lookup(stock["symbol"])
stock["price"] = quote["price"]
stock["total"] = stock["price"] * stock["shares"]
total_price += stock["total"]
@@aristzampaftis6828 gonna have to hop in discord and be patient but I'll help you figure this out: discord.gg/GeTqTCHA
NOTE: taking this line out means that the colspan="4" NEEDS to be colspan="3" in BOTH spots, otherwise the check50 will give an error
@@aristzampaftis6828 I need to know what error your getting - new discord link is:
discord.gg/YPsWnFWW
good for 7 days
You are a literal godsend... I struggled so much with this problem set, like panic attack level and finding this video stopped me from giving up my entire 6 months journey. I cannot put into words how grateful I am that you chose to upload this video to help the thousands of people who like me struggled. I'm sure you already know from the hundreds of people thanking you that you are appreciated, but truly, thank you! On to final project!!!!!
could you submit it bro? the code is working?
Yo my whole project is working perfectly fine bruv did it all by myself but when I do check50 im getting an error on the buy page stating "buy handles valid purchase
expected to find "112.00" in page, but it wasn't found" do you perhaps have a solution for this bruv???
My pleasure! Thanks so much for the support! I'm so happy I was able to help! Appreciate you sticking with it till you found me an congrats on completing this!
@@alialdalate4225 respond to my comments no les than weekly - code still works - update video to prove it - you're good - just stick to it!
@@josiahking2772 This question is answered in the video 3 times, i put it in the description, and I've answered it on MANY comments - trust me that the answer you're looking for is MUCH simpler than you think but if you read other comments, I promise you'll get there.
I love how you are replying to every single person who has doubt even after 5 months of posting this video this is really great. I appreciate your efforts. Thank you so much for your work and dedication.
Lol coding as a beginner isn't easy. Some people just need reassuring. Thanks so much for the support! I really appreciate comments like this!
I am getting error. I have written this entire code for months, but I am getting an error from the api key. Please tell me sir how I add an api key??
thanks Devin. longest 22 minutes of my life 😀
I feel you - making this one was..... intense. Not the code (which wasnt fun) but the video - cutting out all the repeats and trying to trim it down. I did my best but MAN was it a big one. Congrats making it to the end!
Late, but was CRYING and having a full on mental breakdown because I couldn't solve this and all the other tutorials took hours but didn't work. Then... A MIRACLE HAPPENED! I found this video and finished the pset in an HOUR and I am crying tears of joy THANK YOU SO MUCH FOR ENDING MY SUFFERING
Allah Akbar 🙏
Hey, I'm stuck on the sql part it keeps leaving at this ...> can you if don't mind help me out please?
@@Luci_19 make sure you first
cd finance
then
sqlite3 finance.db
then execute your command. Dont forget to get into the sql file first before updating anything in terminal
make sure you end SQL commands with a semi colon;@@Luci_19
Bro you are a LIFE saver. Had most of it, but couldn't find how to reference the session's user_id for the life of me. Thank you!
Happy to help! good job making it this far!
I need help related to finance project please reply me 🙏
are you doing pset9 2024? did the code work for you?
Thank you! This was really helpful. It makes a hard an frustrating problem a good learning tool, there is a lot to learn by going through your video and the completed project. Once again thank you and congratulations for being a person that shares knowledge and helps others.
Hi! Helping others is a big deal for me. I'm so grateful for each comment and person out there letting me know I'm helping so thanks so much for the feedback!
Great Video Brother!!!
Thanks to you i am moving to final Project ,
Thank youuu!!!!!
Keep this good work continue you will definitely Grow ❤❤❤❤
All you my friend! Congrats on completing this! Happy I was here to be a part of this with you!
It does indeed work. As for the part he tells you to do on your own, he drops a lot of hints. Thanks Devin.
You are the BEST! well done and congrats! Hopefully I'll have more helpful stuff this coming year!
I need help related to finance project please reply me 🙏
Helped me out a TONNNNNN!!!!! Didn't officially enroll in cs50 but was using the entire course as a primer for my enrolled Comp Sci courses next month-I think all of this will lay an awesome foundation, and Devin I cannot quite frankly thank you enough for all of this. Smoothed out the major bumps in the road through a lot of the differing projects when I got stuck, and this last project was an absolute beast that would have taken me way WAY longer without your help. THank you so much my man
I'm sorry to be so late to such a nice comment. I can't tell you how much I appreciate you letting me know that I've helped you. I'm glad you're done and hopefully, as I grow this channel, I can continue to contribute to your growth as a coder. Keep up the great work and thanks again!
I need help related to finance project please reply me 🙏
Submission criterias are so strict that even when the app is working as it should, there's still :( marks. Your work has certainly helped me as it's provided the reference I've needed.
By the way, the proper way is to create a stock table and a separately transactions table. At every transaction you add stock AND update transactions accordingly. You return the content of the transaction table to /history table, and that of stock table to the root folder table, accordingly. This allows for purchase of the same stock many times at different values.
As I stated above, your work was instrumental to help me move at critical stages. You are appreciated. Thank you.
In the video I mention 3 times that the money isn't formatted. And it's in the description as well. I did this on purpose because I want the user to find and update these things accordingly. This was a very simple task (as you noticed) so I wanted to make sure people could identify this error, and update it on their own.
Oh okay! I get you now. Did not really watch the video, I just went to a section that puzzled me. Now I edited the comment accordingly@@RealisticResponse
You are an angel and I wish all the best for you and your family. Keep up the great work and helping people, you are an incredible person, congratulations.💟
Thanks so much! Congrats on making it this far!
This helped me greatly. I really do not enjoy the front end aspect of programming and I struggle with it alot. I'm starting my final project and will be done soon. Again, thank you very much for the effort!
Hey! i'm excited I was able to help. Keep us posted on your final! Love to know what people are doing!
Thanks man, your video helps a lot, I just saw the code to clarify some things, borrow ideas and do things that I was doing in 3 or more lines, just to review the logic to do it in one. This is for real a tough one as you said, but it's Cs50, we all know how difficult this course is. I think that despite making the codes work throughout the course, what bothers me most was making the code pass the test, I know that some tests are very useful, but in other cases the lines simply work but the tests go wrong, and you don't even knows where to look for this error, and in which case it is giving an error, even with the help of the course's AI. Anyway, thanks again.
You're not wrong. I've made a few functional codes myself and they didn't "pass" CS50 algo. But I just kept re-working the code until something happened. Good work getting this far and 'hopefully' completing.
I need help related to finance project please reply me 🙏
Hello , I am facing an internal server error here in register can you please help I followed all the steps yet it' keeps showing error
Really though thanks for the video this is super helpful and Encouraging, I finished the lab then came to this one and was like "WUT"
This one is TOUGH dont feel bad. I see now why there's so few video helps for the whole course but this one especially. Good job making it through. Good luck on your project!
Dude you have been such a huge help and inspiration while i was taking this course. This video helps clear up a lot of things for me.
On to your final project I suppose?
Sorry for the delay - been away - but coming back to comments like these make all the difference in the world. I appreciate my subscribers and commenters and supporters more than they know - I'm glad I was able to help you out.
Great solution, before this vid I was stuck with an error 302 instead of status code 200. This pset was TOUGH. Thanks for the help.
Absolutely! Thanks for the shout out! This one wasn't easy but I'm glad you got through it! good job!
hello friend, I'm sorry for not expressing myself well, I would never diminish your work, on the contrary I am very grateful for your help, without it I would not have been able to finish the course, thank you very much
I didn't think you were being disrespectful. I'm happy to help and will do whatever I can. This small thing was just more than i was or am able without a whole other video.
I'm happy to help and happy to see you're completing the course! Thanks so much and dont worry. I'm here to help.
Thank you so much brother I appreciate you and your help, I have been struggling with this problem set until I found your account ✨
I am watching your videos from KSA 🇸🇦
Thanks! So happy I could help! I'm on to CS50W now and then after that I think maybe the MIT course but we'll see where the road takes us!
I am so thankful for you. Today i will be submitting my final project and all thanks to you. This journey would have been impossible without your help. This pset was the most toughest but with your help i was able to do it. You're godsend
Hello man iam too but I still have a problem I fnace it doesn't wana work
Congrats! I'm Happy for you! we all need a little help sometimes. Happy i was able to be part of your journey!
Thank u for all of the help that u provided. Love the content and information. Hugs from Argentina
Such a legend for this, i was starting to get demotivated because I wasn't confident in my logic, but using your guide to proof check what I was doing helped alot with that. Your explanations made it so easy for me to understand what i was doing.
Can tell you how much this means to me. I keep getting downhearted since making these. Not all of the feedback is positive and it gets tough trying to help people all over the world. But comments like this definitely keep me motivated. I appreciate you, and congratulations on making it this far!
brother, can you tell me what he meant in 10:50 , how do I add the codes in the sql file? I wrote the codes in a seperate .sql file and kept it inside finance folder , then i went to sqlite3 and now what?
@@omarhoque1662 I wrote a response on your other comment - hopefully it helps. but get into your sql file b entering the command sqlit3.db to enter the existing sql database (recall sql week and manipulation).
Bro, haven't seen you in a couple of months since ps6 I guess. Thank you for making the code scale larger, the content is perceived in a completely different way.
My pleasure. Onnupdated videos when they come you should see improved visual and sound. Also for future courses. I appreciate the feedback and want to make sure these videos are helping . Glad to see you made it back around! Congrats on making it to the end.
@@RealisticResponse Thanks Devin. It's been a long journey.
Nice video, bro! Thanks for the support, without these type of videos, we can't finish the course... :/
The course is difficult for true beginners I hope that these helped you understand better. Always good to re look at what you've done. The second time around is super helpful now that you have the know how. This is all about practice and redundancy. Good work!
@@RealisticResponse Yeah, totally agree. I'm on the first month studying computer science and I have to say that it was very difficult to me to understand all the stuff. Your videos helped a lot of people around the world, thanks! Hugs from Brazil!
@@caiomac1 man that's hugely appreciated! Thank you so much! Coding is all about working together. The internet was LITERALLY invented to advance science thanks to Tim Berners Lee. I'm for it and I'm here to help. Great job and keep up the good work!
I had this pset going well up until buy where everything got messy for me, but your explanation of how it works helped me a ton. thank you!
Glad I was able to be a part of your success! Congratulations!
Can y help me please it give me this bugs
:( buy handles fractional, negative, and non-numeric shares
application raised an exception (see the log for more details)
:( buy handles valid purchase
expected to find "112.00" in page, but it wasn't found
:| sell page has all required elements
can't check until a frown turns upside down
:| sell handles invalid number of shares
can't check until a frown turns upside down
:| sell handles valid sale
can't check until a frown turns upside down
:| history page shows transactions
can't check until a frown turns upside down
This is answered in many many comments and referenced 4 times in the video. Please see other comments that will help solve this.
That one actually get to me pretty easy, even that I struggle at the more earliest psets...
That's great! This is a tough PSet that shows excellent growth that it's not difficult for you. Well done!
thank you so much for the great help!!!! And your logic is crystal clear , admire you!! hope you all the best !!!
Thanks so Much! Just getting back at it after a break and hope to bring you lots more helpful information! Appreciate you!
Not sure if anyone caught this yet but a critical piece you didn't note in your sell section is the number if shares should be a negative value 17:21 . This is in your code but not mentioned and easily missed. Thanks for the video.
You're a gem. This video was several days of editing. I appreciate the feedback and looking out for others. There was bound to be a thing or two i missed so thank you for helping and supporting others.
I need help related to finance project please reply me 🙏
Thank you very much for your hard work! I have learned so much and finally understood everything!
Thanks so much for the support hearing that you understand is invaluable. Appreciate you so much and congrats!
Hello brother, thank you for your efforts and I hope you will re-explain this problem because cs50 has updated it🙏
There's already an updated video. The changes to CS 50 do not affect the code. the code in this video is correct. Please feel free to watch the short video regarding the update.
I have a problem with the API key. The register page of IEX cloud simply dont load!!!
I dont think 2024 is requiring the api key - can you tell me abit more?
Whenever I click the sell button I am getting Internal Server error. In the terminal it says TypeError: The view function for sell did not return a valid response. The function either returned None or ended without a return statement. Any ideas on what the problem is?
Nervermind, I fixed it.
I WAS STUCK ON THIS PSET FOR FOREVERRR. THANK YOU SO MUCH FOR THIS QUALITY CONTENT!! only suggestion would be to make a detailed video with deeper explanations if possible! that’s something that would help me soo so much to understand why we write certain code. ALSO, for those of you getting the :( on buy handles valid purchase, make sure to test this only after you have formatted the price to match the criteria (2 d.p.)! A hint for this is that you need to use the format function on your index.html!
Since we're already in August, I'm waiting for the 2025 drop and plan to re-do the WHOLE course with better quality. I've improved my PC, My Mic, My Camera, all of it - hoping to do some better, deeper dives to help more people but THANK YOU for you're early support and comments!!!
I need help related to finance project please reply me 🙏
@@cricfever_30 hey, i could try helping! what’s the issue!
@@meera.srivastava bro send me your instgram I'd there we discuss, because I continue to get an error that's a reason. Please reply
@@cricfever_30 how can i help?
didnt understand what 10:50 was meaning , how do I add the codes in the sql file? I wrote the codes in a seperate .sql file and kept it inside finance folder , then i went to sqlite3 and now what? ( i think this is a rookie question but im working on this for 3 hours now)
Sqlite3 finance.db in terminal
@lgachaboyyt the code that he shows in text file...do i keep that code in a .sql file inside finance folder? I did that but it didnt work
@@omarhoque1662 Hopefully everyone here is a bit of a rookie. In case you haven't figured this out yet - watch at 10:45.
You have to enter the slite3.db command to get 'into' your sql file (recall your sql week). then enter the code to update sql, then back out of sql to get back into our regular file.
You shouldn't be writing a new sql fie - there's already one there - having 2 can be problematic.
hello, thankyou for the video --> im a bit confused about the "index section" its showing error expected to find 112.00 something...... can you clarifify what to do to convert the number into USD? timestamp: 15:45
All values need to be in USD format. I have to re-do this video explaining this since it's the Number 1 asked question. There should be lots of help here in the comments section since that one gets asked a lot. Hopefully previous comments can point you in the right direction.
here are the errors I encounter after running your code : :( buy handles valid purchase
expected to find "9,888.00" in page, but it wasn't found
:| sell page has all required elements
can't check until a frown turns upside down
:| sell handles invalid number of shares
can't check until a frown turns upside down
:| sell handles valid sale
can't check until a frown turns upside down
Hey there! So Here's some more hints - First, in the video i mention it about 3 times. Also - in the description there's a hint.
This error means that your totals are not in 2 decimal point formats. To fix this you need to look at your app.py and use a function (see description) to make sure that your total's are giving you the results in just 2 decimal places.
Also look to other comments here. I've had this question the most. I knew leaving it out would cause this, but i needed to leave some things up to the user. The basics of this go back to week 2 i believe so I'm certain once you see it, it will click. Just get that updated and you'll be good to go!
@patrickfaudap7216 Where you able to solve the error? I have the same error and I've been trying and asking for help but no one has replied to my comment..can you help me please?
@@davidninoaguirrecampis6617 You replied to his comment but didn't read the comment I told him on how to solve it. There are dozens of answers I have here helping people solve this same problem. I recommend reading my replies and that might help you understand.
Why you don't show us the hole code only some parts
And i have a question how can i make the flask for all them
I don't show the whole code because people would come to this video to copy and paste. My channel is designed in a way to not make me feel like I'm helping people cheat, but helping them learn. That's the only reason I don't post the whole code as it would be like posting a solution. Hope that makes sense.
As for your question, when you run flask it should run for all of hem if they're properly linked and you're in the correct directory. Perhaps I'm misunderstanding the question?
This one hurt! Thank you for your help:)
Here to help!
Hello, when I check, it keeps ask "buy say handles valid purchase expected to find "112.00" in page, but was't found? How can I solve this
I have the same problem. Do you know how to solve it? Is it becuase of the decimals?
I talk about this 3 times in the video and there's hints in the description and I've answered it dozens of times in the comments Please look to previous comments for help - it's a very simple addition to the code that you need. Please have a look around to see if any of the other previous comments or description help.
@@mario050488 I talk about this 3 times in the video and there's hints in the description and I've answered it dozens of times in the comments Please look to previous comments for help - it's a very simple addition to the code that you need. Please have a look around to see if any of the other previous comments or description help.
print("Thank you Thank you Thank you Thank you!"*10000)😍
thank YOU - appreciate your support! keep up the great work!
@@RealisticResponseI need help related to finance project please reply me 🙏
hey so I have a problem. when i run check 50 this frowns:
:( buy handles valid purchase
expected to find "112.00" in page, but it wasn't found.
do you know what that means?
oh wait check50 is different from when you did it with your other video. hmmm.
Did you solve the issue? I am struggling the same error((
@@xsenyus7521 it is a bit different but the issue is the same. This comment is the number one question and there are lots of responses and comments that help solve it. I also mention this 4 times in the video. All values must be usd which is defined in the existing code. If you convert all values to usd this should solve your problem.
If that doesnt make sense, look to previous comments as we've solved it many times. That should help.
Hey Devin..!! its been over a week I'm working on finance but getting errors in sell function. some are those errors which I can't understand where I screwed up, when I execute check50 it even can't check any function.
Hey there, you're not giving me anything to go off of here. I understand something is broken but you're kind of just telling me nothing is working. I can't really evaluate the depth of the issue. This should have take a while, over a week isn't uncommon - but you should have been testing at every stage and every html extension. if you did this then we can identify the error. or if you have an error message... but telling me nothing works is the same as telling me 'i have no code' - i just dont have anything to imagine where the problem is or could be.
I have submitted exactly. what you have shown in this video, yet I am receiving a score of 1/21, am I. missing something?
Most definitely. What happens on your check50? where are the errors? you have to find and debug. This is a very tedious project and you can't be missing anything but you should not be receiving a 1/21.
what is the grand_total variable for in the index function?
A previous version I wrote. It doesn't serve a purpose. I was going in a different direction and left it in. but it is a dead line of code so shouldn't impact yours if you do not use. This video took so long to do, removing something I didn't end up using in the end became to tedious so it died in-line.
:( buy handles valid purchase
expected to find "112.00" on the page, but it was not found. I get this from the check50 but how can I solve this?
Or this: :( buy handles valid purchase expected to find "9,88.00" in page, but it wasn't found
By check50 sell I get sell page has all required elements, sell handles invalid number of shares and sell handles valid sale but with all of these can't check until a frown upside down
Hey Sabine! One way is to update the app.py file using float logic and USD() I mention this twice in the video as well as in the description. This part is up to you. At this point in the class if you've been following along and following with my videos you should have the know how.
You need to get your index to return totals in 2 decimal places - how you do that is up to you but it is required for the final.
SELL, BUY and LOGIN buttons all give me internal server error. Can someone help? :(
error codes please
I need help related to finance project please reply me 🙏
Can someone please help me I've been working on the project for several hours but I can't get rid of this error code: “expected to find "9,888.00" in page, but it wasn't found”. Thank you
Hey there! There are dozens of comments regarding this issue and I cover it twice in the video. In your app.py you need to implement the usd or float function to get your totals on income rounded appropriately. You're very close and this is early cs50 logic. You can get there. Use one of those two logics so that your balances are rounded to 2 decimal places.
@@RealisticResponse Thank you for the answer. Even though it's so easy, I still can't seem to figure it out. Can you please show me how to solve the problem?
@@luc_kht I can help you solve this but you have to hop in discord. I cant give you the answer but I can help get you there
Thank you :) You are a life saver
Thanks for the support! Almost done!
Hello Mr. Finley, is there any way that you can make a 2024 version? I tried using your code but it did not work. Thank you for your videos, I couldn't have done most of the course without you. Please consider making a 2024 version soon...
:) app.py exists
:) application starts up
:) register page has all required elements
:) registering user succeeds and portfolio page is displayed
:) registration with an empty field fails
:) registration with password mismatch fails
:) registration rejects duplicate username
:) login page has all required elements
:) logging in as registered user succceeds
:) quote page has all required elements
:) quote handles invalid ticker symbol
:) quote handles blank ticker symbol
:) quote handles valid ticker symbol
:) buy page has all required elements
:) buy handles invalid ticker symbol
:) buy handles fractional, negative, and non-numeric shares
:) buy handles valid purchase
:) sell page has all required elements
:) sell handles invalid number of shares
:) sell handles valid sale
:) history page shows transactions
As Of 08:50AM on 27, January 2024 this code still works. although, AS MENTIONED, you need to convert to USD - the only check that has been added is for a $28.00 on history page which, as mentioned in the video, means you have to convert "price" on your history page to 2 decimals.
This code till works.
@@RealisticResponse Thank you, sir. I'm very grateful for your help, have a great new year
buy said symbol not found :( buy handles valid purchase
expected to find "112.00" in page, but it wasn't found
Did you ever find a solution?Im having the same issue
nvm I found the issue. I'm sure that you have already fixed it, but for anyone struggling in the future, you need to make sure that your index uses the "usd" function. {{ stock.price | usd }}
{{ (stock.price * stock.total_shares) | usd }}
@@ext1nct297 i have the same issue for days now...When you say "index" you mean that it needs to be displayed in usd format on the main page where index table is shown?
You found the hidden key! Great work @ext1nct297 well done!
He means the code on the index page needs to be converted to usd - I mention it several times in the video and in the description and multiple comments. convert your totals to usd and you'll be good to go
Thanks for your help ! 😇
Absolutely! My pleasure keep up the good work!
That was awesome explanation
Great! Thanks Finley
Thank you so much and congrats on making it this far!
I got one question: In the Index function what's the point in having two variables total_value and grand_total that always have the same value?
Ok... hear me out.... ORIGINALLY I'm a finance major. So when I was writing the code I intended to use Total Value as the total value of just the stocks; and Grand Total as the value of the stocks AND the cash balance. As you correctly pointed out, in this code,
total_value += stock_value
grand_total += stock_value
They ended up being the same. And this video took so long to make that I wanted to chuck my computer out the window. So I never went back and changed them to the parameters I originally meant to use. So... I knew i'd get called out eventually... but I was in too deep. lol and i left it. But that was the original plan.
Hello,
I've been trying to solve the CS50x problem since a month but I am still unable to. The only set left is this one. Is there any correct solution form where I can copy the code and learn from it. I'm really tired now.
Hey there. I don't have a cheat sheet. This video can help you solve the issue. The code and explanation is all there. Don't feel bad if you have to take a break. But i don't have the outline as an answer sheet posted anywhere.
Finally!!! Thank you you're awesome ❤
Let's go! Check the recent video for a giveaway. Gratz making it this far!
I do have a problem with the sell function. Even though I applied the usd() function everywhere I could, I still get the error: expected to find "56.00" in page, but it wasn't found. 😔. I'm so tired of this error.
Check your html and app.py and make sure you've implemented the cash function - if you run your page and look, you need to get down to 2 decimal places - to do this, you have to use the cash function - there's a LOT of comments here that help answer this question. you're very close - it's honestly simple enough that when you see it you'll kick yourself at this point.
Hi Devin, I have all the code and checked that my sql table was updated but I am still having trouble with my buy page. Here is my error :( buy handles valid purchase
application raised an exception (see the log for more details). Everything else is working on the site.
this should be in your buy function in app.py - theres something missing telling the program what to do when executing a buy - it has to do with the function that updates the sql to add a share and subtract the cost of it.
I'm having the same issue. How did you resolve??
Thanks Devin! you are the 🐐
Congrats on making it this far. Happy to help in your journey!
How to fix 500 internal server error in the registration, I have index.html but still the same issue
That error is too vague. I don't know what the problem is based on that error. you're going to have to hop into discord or elaborate because the error provided doesn't give me enough information
Issue found, I followed the same things that you did but after selling shares, number of shares is not reducing, you did something that you haven't showed here
Hi there. I assure you that's not the case. The issue is in the sql command for your sell shares. I made sure not to leave anything out - I was recording my screen the entire time and content was only shortened for speed but nothing critical was left out. This code and the functions within I've tested hundreds of times. The Issue is most likely in line 259(ish) on the db execute
@@RealisticResponse brother, I solved it. By the way, after changing this line, it works: db.execute("INSERT INTO transactions (user_id, symbol, shares, price) VALUES(?, ?, ?, ?);", session["user_id"], symbol, -shares, -price)
Thank you so much for your video it was helpful. I am having an issue with My login, it returned an error saying expected a 200 status code but got a 400 status code.
What can I do
Same
Do you got any solution
I also need help... been on that error for a week now
@@preciousadedamola8294 this is too vague i dont know where your error is. 400 means bad request. but i'm not sure where you're getting it. this is a whole application. the 400 could be getting thrown anywhere.
@@fantasticearner3415 @preciousadedamola8294 this is too vague i dont know where your error is. 400 means bad request. but i'm not sure where you're getting it. this is a whole application. the 400 could be getting thrown anywhere.
Please Help :) I am receiving error: :( logging in as registered user succeeds and log reason is: exception raised in application: RuntimeError: no such column: name. I tried updating sql by going through the steps you suggested with creating a new table but when I try to do that I get : Parse error: table transactions already exists
CREATE TABLE transactions ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTE
^--- error here
no such column name implies the original built-in sql rows might be missing. when you open your sql and view tables you should have 2. The one you created and the one it came with. Can you verify both tables exist within the sql file?
@@RealisticResponse thanks you are right I made a typo and added 'name' once I removed that word everything went through fine.
@@WTDTravelChannel Great work! good debugging! Congrats on making it this far!
Somebody please help me out. I'm getting the error under "buy handles valid purchase"
```
sending GET request to /signin
sending POST request to /login
sending POST request to /buy
exception raised in application: TypeError: 'NoneType' object is not subscriptable
```
I went trough everything printed out every value, double-checked every condition and still cannot find what is the root of the problem. I'm not returning a None value to anywhere.
I can tell you with certainty; you're overlooking something. The error indicates a but function purchase which could be sql related, but you also may have errors in each portion of your signin, login, and buy. without seeing your code, it's difficult to discern but it sounds like a sql issue. You either aren't starting with the amount of money required, or adding shares to table, or reducing money from purchase - something like that.
This code has worked for thousands of people. If you take your time, you'll find the error. This is part of programming is identifying bugs. something is missing. or tabbed wrong. or you used - instead of =. any of these could be the issue. you have to be patient with the code.
My code and this video are a guide. by this stage in the course you should be able to read it. you should be familiar with debugging. read the error, read the code, be patient, and update accordingly. This is all part of programming. It's something you can't stand against and must embrace is this is the path you wish to take.
Awesome been waiting for this lol
It has ARRIVED! lol took me some time hope it works.
Am I the only one who is getting:
:( logging in as registered user succceeds
expected status code 200, but got 404
in check50?
Let me know if you still need help sorry for delay. Back now.
i am having a error with my check50 it says that "unknown file type......skipping" to all html and css files.sir can you please help me this?
and my finance is working fine.
it is also saying that can't check a frown until it turns upside down
please sir please help me with this
The only thing that I think could be wrong is your file extensions and/or locations.
you need to make sure all html files are labeled ".html" and are nested inside the "templates" folder. you need to make sure your .css file is labeled as such and is nested in your "static" file folder.
The only thing I can think is that your files and folders are likely labeled wrong or messed up somehow.
@@RealisticResponse a lot thanks sir I fixed and got my certificate🥰🥰
@@ritvanriteshpartapsingh174 WELL DONE!!!! Congrats!!!! I'm happy for you and good job sticking to it!
Hello Sir, I am getting " Runtimeerror: no such table: users " when trying to register a new user. Please help!
sorry for delay, please let me know if you still need help
I need help related to finance project please reply me 🙏
I get stuck at the register page (can't login & can't register) @5min45s. Anyone else ?
Hey! Havent heard any issues here. Did you create the sql file so that when you register a new user it has somewhere to save that info and then log them in?
Try checking your margins and making sure they are tabbed out properly! And also make sure everything is spelled correctly.
Hey I encountered an error and not able to resolve it on my own can any one help me.
The error is
:( buy handles valid purchase
Cause
expected to find "9,888.00" in page, but it wasn't found
Log
sending GET request to /signin
sending POST request to /login
sending POST request to /buy
checking that "112.00" is in page
checking that "9,888.00" is in page
This is a COMMON question. Please see details and pinned notes. In the video I mention I did NOT solve this and its up to you to complete the app.py to get the digits of the numbers on your login screen down to 2 decimal places. You can use FLOAT or the built in USD or anything similar but you need to get the monies down to 2 decimal points to complete this task. Its mentioned in the video a few times and in notes I left on cideo
@@RealisticResponse Thanks for informing I eventually solved this problem by FLOAT logic. Thanks for this tutorial It helped a lot.
@@akashvasava8243 EXCELLENT! well done!
Does anyone know that if there is a link that we can download the code?
Howdy howdy, I don't have a link that directly provides the code but I do have a discord where I try and help out if you're running in to issues.
Hello Davin this code going error so much give me a solution please . I am still coding 24 hours continuously but i stuck please
Hey bud. This code has been checked over and over again. The code is right. If you're getting that many errors you may have to start over. patience and understanding is key here. testing is paramount. you should be testing at each stage to find errors. If you're not testing until the end and you're riddled with errors it will be impossible to find the bug. There are not detrimental errors in this code. I would recommend taking a break and starting over. When you do, test at every phase to identify errors. Do not try to complete the whole code and debug at the end.
@@RealisticResponse thanks brother but please one time you again get video of update finance just like that the previous video . I used pervious code of finance but finance is update thats why i see errors i think . I hope you update finance to another good video step by step to like 1st video of finance . thanksgiving
@@zubijaved10 I have tested finance dozens of times and made a second video showing all the testing phases quite recently. The code is correct in the video. There aren't any errors.
There is a new video regarding the update and it shows repeated testing for accuracy. This code works.
@@RealisticResponse yes you write ok i try again to solve this you a great youtuber good bless
Hi Devin, when you are adding the transaction table am I inputting that information exactly. You had it on a notepad but where did you put the code?
so you're going to update it in sql.
In your terminal (just like when we did sql) you're going to type:
sqlite3 finance.db
that will open the sql database and you'll update the tables with that code. Once you're done just exit SQL and get back to the code. Does that help?
Thank you! @@RealisticResponse
@@RealisticResponse I put it in my terminal and got out of it ran flask run and it still isn't working. In my history on the website it isn't listing the transaction type. I have it in my html. and I have it in my updated table but it's still not showing up.
@@jessipresten9042 my pleasure!
@@jessipresten9042 It wont show up unless you sql it and look for it. you should be able to view it if you .schema what do you mean it's not showing up?? changes to sql dont just show up - they're built into the database so its not something we see unless we pull it up like i do in the video or run .schema or run .tables or something.
im having some trouble with the quote part. When i click get quote, the correct quote names dont show it just shows whatever i typed for the quote name and symbol. Please help Devin
I must be misreading this. When you lookup a quote it shows you the quote price right? I think I'm misreading this. If you can explain further I'll see what I can do.
Hi for the sell page every dropdown option seems to be blank, as in its literally white space, this makes it so all symbols are invalid, not sure why.
Stock Symbol
{% for stock in stocks %}
{{ stock['symbol'] }}
{% endfor %}
when I inspect the page it gives this:
So i've noticed some users (like mac users) are having trouble with the drop down - instead of using the drop down tr coding your sell more like your buy - using input instead of drop down. Should help fix it.
THANK YOU SO MUCHHHH!!!!!!i've finally finished this pset!!!!
I need help related to finance project please reply me 🙏
I have a question about this problem.
I found this this problem very difficult, and to be honest, I couldn't do anything on my own. That's why I watched your tutorial.
Since I've paid the fee for the verified certificate with a 90% discount from edX, I've been wondering:
" Is me using most part of the code you provided in the video against the academic honesty? Can I lose my certificate because of it? "
I really wanted to finish this course without any help from the internet, but it's just too difficult for someone like me who hasn't got a great CS knowledge.
Could you shed some light on this point please?
No, you wont loose your certificate
@@hi_eklavya Thank you, really relieving.
My videos are meant as guides. But to answer your question let me ask you this. If you're in a group project at school. And there is a portion you dont understand, but as a team they help you and explain to you so that you DO understand. So you use the value they've given you. Do you view that as cheating? This video took me a LONG time to make and I've spent countless hours continuing to help people since posting it. the value of this video is to help you learn. not for you to copy - there are also countless changes you can make if this video helps you understand. But if you don't understand, how are you to learn and continue? I hop this better answers your question.
Brother i want ask how when i create table they say transactions is error like what is missing ?
This is covered in a few comments below. as well as in the video. your have to remember your SQL week.
go into sqlite3 finance.db and update the changes necessary.
in your terminal go into sqllite3 finance.db - update the sql database. it's explained in the video and sql should be part memory from your sql week - it's a very small update just to get the tables in
@@RealisticResponseso i should do in my terminal cd finance the sqlite3 fibance.db or sqlite3 finance.db directly aftter that like i put the create table transcations etc.. right?
@@RealisticResponse cuse when i click quote apal its great but then buy and sell and history not working i thinks its becuse sql not update i really want do it cuse its my last chance begore new year💔
@@clips1363 you have to click on the sql portion of the video and make sure you've made the changes to the database. It's all here. Go to the sql
@@clips1363 cd finance
sqlite3 finance.db
Be in the finance folder first always a best practice.
Thanks buddy this helped me a lot
Congrats! Hope your final project goes well!
It tells me that there's no such table for "USERS" in finance.db. Anyone got any ideas on how to resolve this?
your finance.db is broken - this is built in when you import our wget. try this
cd finance
sqlite3 finance.db
CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username TEXT NOT NULL, hash TEXT NOT NULL, cash NUMERIC NOT NULL DEFAULT 10000.00);
CREATE UNIQUE INDEX username ON users (username);
this is the built in code in finance.db that has users. missing users is an issue as it's built in to your wget and should be there inherently
Do you know why I keep getting these two errors?
:( registration rejects duplicate username
sending POST request to /register
exception raised in application: NameError: name 'checkUsername' is not defined
:( registering user succeeds
sending POST request to /register
exception raised in application: NameError: name 'checkUsername' is not defined
The function you're using "checkUsername" in your app.py is not properly coded. My guess is the register function based on the error. You need to reevaluate the code in this portion where you define "checkUsername" to make sure it's accurate.
Thank you so much for the video, helped me understand the concepts a lot more but there is one error that keeps showing up and idk where. It's within the buy function as it says a float is not iterable and gives me a type error, although it says the buy handles the purchase. If you could point me in the right direction, that would be awesome! Thanks again
I can. Try defining float in your index function. Defining it early will clear most things up. Otherwise - consider using the built in 'usd' function. if that doesn't make sense - drop a line in the discord and I'll help get it sorted! you're almost there!!!
I got this error - AssertionError: View function mapping is overwriting an existing endpoint function: register
means you've defined 'register to have 2 endpoints somewhere in the app.py function? This doesnt make sense.
What stage of testing were you at when you got this error? It has to have something to do with your
@app.route("/register", methods=["GET", "POST"])
def register():
function.
make sure you have NOT 'def register' twice - that's the only thing I can think.
hello! Great video. Just asking at 5:23 on Line 8 it states "url_for(register" is this the part where we paste the image or is this text necessary? Many thanks! 😁
Hi! The text is necessary. In that line (which we have on all .html files) the program is using html and flask to find and load your 'register' route/view.
Its an html FORM that will POST a request to the listed url in the app.py file. Does that help?
Hello, I have this problem
:( logging in as registered user succceeds
application raised an exception (see the log for more details)
this isn't the error code I need. there's an error in your "register" function most likely. spacing, "s or something like that... I dont know without the error message.
eror is:
:( logging in as registered user succceeds
Cause
application raised an exception (see the log for more details)
Log
sending GET request to /signin
sending POST request to /login
exception raised in application: RuntimeError: no such column: stock
@@RealisticResponse
@@rezasafari6483 Error has to be in register. login i'm pretty sure is built in.
No such table Stock means you didn't adequately update the SQL file.
This sounds like the code has errors from the start could be typos, missed " or spacing (tab) issues. but it sounds like failure to launch. Not too much I can say except look at loops and spacing and spelling etc - take it slow and start over might be a thought too if there's issues from the beginning. Remember to TEST AT EACH STAGE. without this you'll never find errors.
Hi you have been so helpful. Thank you for your help during this process. I am getting so close to finally finishing up and sadly im not able to get thought the problem of this last code. it keep coming up ":( logging in as registered user succceeds application raised an exception (see the log for more details)" not sure what that problem could be. could you help?
didn't get a notification about this comment sorry. But the error is in your log. do you have an error you can update me on?
I followed you but the website still doesn't recognize me and I don't know what to do. You did a great job
Thanks for the support. Your problem is too general though. This code works. It's been tested thousands of times at this point. So something is off in yours but I'm not sure what. If you can be more specific, i may be able to help.
When I run flask run and click on the thhif file, it shows up on the website but it doesn't have a register or quote or buy or sell. The entire website is still the same as when I first opened the source code. Thank you bro.
@@RealisticResponse
When I followed you, you watched the video details, but after the code was finished, it was not linked together, what should I do? Please help.
@@RealisticResponse
Guys, be careful when creating the files for your templates because if you just go to File - New File, the default option is to create your html files in the Finance folder, and you want them in the Templates folder :D Yes, I was that idiot who didn't pay attention and re-wrote the code 1398203 times for no reason ... :D
Thanks so much for sharing this! It's invaluable information lol we've all been there and sharing our mistakes will always help others avoid them. This is why i love the coding community! Keep up the great work!!!
@@RealisticResponse I still cant believe the silly mistake, but that's why I shared it also, I can imagine other people doing the same thing :D
@@TeamUpWithAI lol understand completely. But I'm glad you found and shared. Thanks again!
LOL this happened to me multiple times had to restart so many times
@@RealisticResponse wait so if I made a transactions.sql file for the transaction table, that should go under the template folder?
sir i have three errors
1-> quote handles valid ticker symbol
expected to find "28.00" in page, but it wasn't found
2-> buy handles fractional, negative, and non-numeric shares
application raised an exception (see the log for more details)
3-> sell handles invalid number of shares
expected status code 400, but got 200
please help me
i spend many days on this errors
Hey Pirate. I mention this a few times in the video and in the description. You need to update app.py function where on your index it gets the decimals down to just 2 decimal places. This part of the code is up to you. review your INDEX function on app.py and update the code so that it's NOT unlimited 0's after. get it down to TWO decimal places using FLOAT or the already defined USD. I can't give you the solution but that is the HOW on how to fix that.
Hi! When I try to buy shares the “shares must be a positive integer” but my code says
“Elif not shares or not shares.isdigit() or int(shares)
Sorry for the delay - been away - let me know if you still need help.
Hello i think i need your help, i did the code exactly like yours , but it gives me a error message saying " expected to find "9,888.00" i page, but it wasnt found" (i did exactly like yours because with my changes to your code it gave me the same error message) any help?
I mention this 3 times in the video and in the description and in many, many comments. Its a very simple feature that I left out on purpose but if you read through some comments here you'll find the help you need to solve.
Hey, I ran check50 and got the following
:( registering user succeeds
IndexError: list index out of range
:( registration rejects duplicate username
IndexError: list index out of range
I don't understand this error, could you help?
index out of range
Go through your app.py and look at the SQL Commands.
# Query database for username
rows = db.execute("SELECT * FROM users WHERE username = ?", request.form.get("username"))
In the history page, is the column Type supposed to be empty? Are we supposed to tell whether is a buy or sell transaction?
You could add buy and sell to the table but the + and - in front would indicate a buy or sell. but yes. I love the idea of adding this to the table.
Why do I get the error message: "return can only be used within a function"? Do i have to implement the whole code first, before running flask?
Absolutely not. nor should you. You should be testing your code at each stage to find things like this. This error is telling you precisely that whatever portion of the code you're working on, the "return" function is not in the right loop.
The error is likely in your app.py file. make sure the return function is properly tabbed.
Does this video also work for the 9th week of the cs50x course of 2024 and give us the correct answer?
Last time I checked (Early feb) the answer is yes - I took a few months break and am getting back to all weeks and updating videos.
Could you update the video, please? I have been issues with my code on July
Last I ran this code it cleared all green - I've run it thousands of times now. It will get an update in 2025 as it seems to still work. This particular video is a huge undertaking. Perhaps if you elaborate the problem I can assist.
I need help related to finance project please reply me 🙏
Thank you so much for the video, helped me understand the concepts a lot more but there is one error that keeps showing up and idk where. I tried everything i could and it didnt go away I thought it may be bc the usd function but i fixed it and i still got this error::( buy handles valid purchase
Cause
application raised an exception (see the log for more details)
Log
sending GET request to /signin
sending POST request to /login
sending POST request to /buy
exception raised in application: TypeError: unsupported format string passed to Undefined.__format__
Hey. Not sure what lead you to believe this was a usd issue. usd is defined in helpers.c with no need to adjust so i can't see why it would be usd but i suppose its possible. My knee jerk reaction is i could be a few things:
Template syntax - missing or improper curly braces or parenthesis where you might be using blocks or extending blocks would be my first guess.
URL Endoints - incorrect endpoints ir misspelling of urls and or names thereof
SQL queries - make sure the table is setup correctly to register buy/sell
The issue here is i'm not sure WHERE during your testing phase this error occurred. If testing happened only at the end of coding then it's difficult to pinpoint.
Something tells me it wasn't the usd function - may be much more simple than that. as simple as a typo.
@@RealisticResponse thank you, that is right. I fixed it.
@@yy1ummz88 :whew: ! good job!
I Have a problem in check50 with something called "can't check until a frown turns upside down" how do I solve it?
There's an error and you have to check the log to see where and what the error is. Check you're error log like you've been doing.