Week 7: Finance – Will

Screen Shot 2015-11-01 at 7.29.39 PM

The past two week’s blogs have taken a step away from my course work; examining both the startup I’m working on (which does have a fancy new website) and some of the greater implications of the work I am doing. As we come close to the end of my work in this course, with only four weeks of lecture to go, I think it is important to return to our focus, the actual core work of the class itself. This week will will be examining Pset 7: CS50 Finance


If you have made it this far into my series of blogs, I hope you have an idea of the concept of a programming language. Essentially, programming languages are designed languages with syntax and structure, and are readable to those who speak them, and are much like natural languages. However, instead of being used to convey ideas from person to person, they are used to convey ideas from person (the programmer) to the compiler, the thing that turns the language into assembly (the one to one instructions for the computer). So far in our course work we have been using a language called C. Which has been around in some form since 1972 when Dennis Ritche first designed it’s syntax, although the language today has evolved since. In Pset 7, we are taking a step away from C and learning a new language called PHP. PHP is notably much newer language, though less widely used, at about half the age of C itself. PHP is language built from the ground up for the web. It is meant to deliver interactive and intuitive web experiences that you interact with every day.

A High Level View of Implemantation


As this PSet is much more complicated then the past ones, it does not make sense to walk through each method step by step. Instead, what follows is a high level view of the kind of thought that goes into solving this type of problem. Since this is a longer PSet, two weeks, I don’t actually have all of it completed, so we will only be walking through the first half of the problem.

The Idea of C$50 Finance is to simulate a stock portfolio using a web application we construct. Instead of actually buying stock, we will scrape data from Yahoo Finance and simulate what would happen if you bought and sold at certain points. So from the highest level, we have to be able to log in, we have to be able to buy and sell, store what stocks each user holds, and then view history of a stock.

Screen Shot 2015-11-01 at 7.51.36 PM

The first logical step would be to handle logging in and logging out. So simply, we have to set up a page with a username, password, and confirmation password fields so that a user can make an account. Once a user makes an account, we salt and hash their password so we don’t store it unencrypted and then we pass it onto a database. Our database in some ways is basically a really complicated excel file that we create using an open source tool called MySql, the same tool Facebook and many other huge companies use. Once the user makes an account, they are able to log in and begin to use the tool. Logging in is simple, we search the database for the username and entered and if and the password matches then we can log them in.

Screen Shot 2015-11-01 at 7.55.35 PM

The next feature to implement is the stock price ticker. Essentially, we are pulling all of our data through Yahoo Finance , which is an amazing tool that lets us download stock histories at a small delay for free. So when a user enters a stock symbol, like APP, we query Yahoo for the stock, download it’s history, store it to our database, and then show it to the user. The file we download it as, the CSV format, is a really simple spreadsheet format that we can do all kinds of magic with. However, as it’s implemented now, we are just going to show the user a price.

This is where the first import design decision comes in; how do we query this stock data. When first examine the problem it makes sense to simply take all of the data Yahoo Finance has, and mirror it in our data base, and update it as frequently as possible. After all this means we don’t have to tediously search query Yahoo everytime a user enters a ticker name. However, database sizes are finite, and with the NYSE trading 2800 companies alone, this data quickly adds up. So we must make the design decision to only sample the data we need. We will only request data for stocks that either the user owns, or requests a price for, and only store a small amount of their historic pricing data. While historic pricing data is important for bankers, this is simply a simulation, and it is probably good enough to ignore anything that didn’t happen three or four days ago. This means instead of requesting gigabytes of data everytime Yahoo Finance updates, we only request a couple kilobytes, which is much more sustainable.


A Pre-Post-Mordem

To an extent, I realize this blogpost reads as unfinished, however that is because the work is ongoing. This is a longer problem set and I will not have my final implementation done until this Friday. This week’s blogpost is mainly an introduction into the process of learning a new language and an introduction to some of the decisions a programmer makes while considering how to solve a larger problem. A even higher level introduction to Pset 7 and the finished implementation of C$50 Finance will come this Friday


2 thoughts on “Week 7: Finance – Will

  1. randyhimself

    I could use so much help from you when I finally learn what all the data represents in my independent. Solid. Solid. Solid. Sounds every bit of professional as it deserves.

  2. realrowo

    Will, great work in presenting your work through such a clear and professional blog! I have always been admiring those who are able to connect computer science and other technological knowledge with finance and the business world, and I am glad to see you exploring it. I also like how you search for help from major sites like Yahoo. Not only Randy but also me are going to benefit from your work. Thanks for such a inspirational blog post!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.