hows it going?

This commit is contained in:
William Mantly 2015-07-07 17:51:13 -04:00
commit 0603937853
8 changed files with 65 additions and 0 deletions

4
README.md Normal file
View File

@ -0,0 +1,4 @@
Week 3 Day 3
============
Today you will be using your first api and bringing it together with the MVC pattern to create a terminal app. We're starting to bring things together. Have fun with this.

View File

@ -0,0 +1,23 @@
## Markit API Wrapper
Today is your first challenge using an API. Cool!
First install 'requests' using pip3. We'll be dependent on this library, as it is definitely the best [HTTP request library](http://docs.python-requests.org/en/latest/) in Python. Take a look at the code snippet and get an idea of what it's doing. We'll be using requests to get live stock market data.
The API we'll be using is [Markit on Demand](http://dev.markitondemand.com/)
How do HTTP requests work? Well, everytime you browse the web you are making http requests. You are asking for data from a URL. Your browser usually expects data in the form of HTML.
We could request HTML in our code also, but it's kind of a mess. Instead we're going to request [JSON](http://en.wikipedia.org/wiki/JSON), which Python will treat like a native object courtesy of the requests library.
Take a look at these links so you know what to expect from the API. Read through the docs for Markit on Demand.
http://dev.markitondemand.com/Api/v2/Lookup/json?input=Netflix
http://dev.markitondemand.com/Api/v2/Quote/json?symbol=AAPL
#### Step 1: Wrap the API calls in an object
Wrap the calls to Markit on Demand in a class. I've already started it for you. Write the methods get_company_data and get_quote. company_search takes a company's name in English and returns some basic data, like the formal name, the exchange it is on, and most importantly it's ticker symbol. The API will likely return more than one. get_quote takes a ticker symbol and receives up to the minute quote data.
#### Step 2:
Test that your functions are working in the python interpreter. What happens if you send an incorrect string and it can't find the company, does it throw an error? Fix this - we don't want your program crashing on users.

View File

@ -0,0 +1,12 @@
import requests
class Markit:
def __init__(self):
self.lookup_url = "http://dev.markitondemand.com/Api/v2/Lookup/json?input="
self.quote_url = "http://dev.markitondemand.com/Api/v2/Quote/json?symbol="
def company_search(self,string):
pass
def get_quote(self,string):
pass

View File

@ -0,0 +1,22 @@
## Terminal Trader
Now it's time to make our stock trader game - remember, greed is good.
First, import the wrapper you wrote around the Markit API. We're going to need that functionality.
Our game is going to give users a starting amount of money - maybe $100,000? and let them buy and sell stocks based on the current market info we get from the Markit API. It should update their earnings whenever they login. There should be an admin who can log in and get an up to date leaderboard.
#### Step 1: Database
Design your schema. We're definitely going to need a users table. What else?
#### Step 2: Implement Functionality
To play our game, our users want to be able to search companies and get the exact stock ticker symbol we want. Our users also want to retreive the market data for a stock before they purchase it - we should obviously show them today's price, but we have alot more information at our disposal that will help the player make an informed decision. Start with just an interface that lets the users access and see this data.
#### Step 3: Game Logic
Now make it so users have the option to "buy" and "sell" stocks. Buying should subtract from their funds and not let them buy more than they can afford, selling should return money to their cash funds and not let them sell more than they have. Of course, users will need to buy and sell at the current rate.
#### Step 4: More Game Logic
Create a user dashboard that lets the users view their portfolio, the amount they have earned or lost, the amount of liquid cash they have available, etc. Make sure they are never looking at stale data. Think of some cool extras - maybe how their portfolio compares to the market average for the year?
#### Step 5: Leaderboard
Create a superuser who can see a leaderboard that displays the top 10 users by portfolio earnings. Copy their strategy. Make millions!

View File

@ -0,0 +1 @@
import sqlite3

View File

@ -0,0 +1,2 @@
import bank_models
import bank_views

View File

@ -0,0 +1 @@
import sqlite3