CS50 Finance: Building a Website for Buying and Selling Shares

In this video, we learn how to solve problem set 9 of CS50 by building a website for buying and selling shares. We handle registrations, check stock prices, track transactions, and display user information.

00:00:01 In this video, we learn how to solve problem set 9 of CS50, which involves building a website for buying and selling shares. We start by registering for an account, inputting a username, password, and confirmation. We handle cases where the inputs are blank or the username already exists. We also check if the passwords match.

πŸ“š This video is a walkthrough of solving problem set 9 of CS50's Finance module.

πŸ’» The goal is to build a website where users can buy and sell shares, requiring registration and login functionality.

πŸ”‘ To access share values, an API call is made using a registered API key.

00:13:37 Create a registration function that hashes and stores user passwords. Implement a quote function that allows users to check stock prices.

βœ… Registering a new user by hashing their password and adding them to the database.

πŸ”’ Storing user information using session and redirecting them to their account after registration.

πŸ“ˆ Implementing a route to allow users to look up a stock's current price.

00:27:14 In this YouTube video, we learn how to handle API calls and display stock information using Flask. We also create a buy route and a transactions table to track user transactions.

βœ… The lookup function in helpers.py connects to the API using an API key and retrieves stock information based on a symbol.

πŸ“Š If the stock symbol exists, the lookup function returns the name, price, and symbol of the stock. Otherwise, it returns that the symbol doesn't exist.

πŸ’° The quoted.html file receives the stock information from the lookup function and displays the name, price, and symbol of the stock.

πŸ“‰πŸ“ˆ The buy route allows users to enter a symbol and the number of shares they want to buy. It checks if the user can afford the shares at the current price and updates the database with the transaction details.

00:40:50 A solution is provided for the CS50 Finance problem set 9, demonstrating how to buy stocks, update user information, and display transaction history.

πŸ’° Calculating the transaction value by multiplying the number of shares with the stock price.

πŸ’Έ Checking if the user has enough money by comparing their cash with the transaction value.

πŸ”„ Updating the user's cash by subtracting the transaction value and updating the transaction table with the user ID, symbol, shares, price, and date.

00:54:26 Created a table in HTML to display user information from a database. Used a loop to iterate over the data and display it in the table. Fixed issues with grouping and displayed the total amount.

πŸ’‘ Extract relevant information about the user and their transactions to display in a table on the website.

πŸ’° Calculate the total amount of shares and cash the user has.

πŸ“Š Create an HTML table using the extracted information to display the user's portfolio.

01:08:01 Learn how to add a total row to a table and create a sell feature for stocks in an app using Flask framework.

πŸ’‘ Creating a new row in the table to display the total cash amount.

πŸ“Š Implementing the sell functionality to allow users to sell shares.

πŸ”’ Performing various checks to ensure the user enters valid information and updating the user's cash and transaction tables accordingly.

01:21:39 (CS50) FINANCE - PROBLEM SET 9 | SOLUTION. The video demonstrates how to group and display user transactions, allow users to add cash to their account, and handle errors in a finance application.

The video covers the implementation of a feature that allows users to sell shares based on their account balance.

The video shows how to summarize and display the user's transaction history on their account.

The video also demonstrates adding a personal touch by allowing users to add additional cash to their accounts.

Summary of a video "(CS50) FINANCE - PROBLEM SET 9 | SOLUTION" by Dors Coding School on YouTube.

Chat with any YouTube video

ChatTube - Chat with any YouTube video | Product Hunt