Skip to content

Instantly share code, notes, and snippets.

@r1ckhenry
Created October 20, 2015 12:46
Show Gist options
  • Save r1ckhenry/debcedb82db239fa1aa8 to your computer and use it in GitHub Desktop.
Save r1ckhenry/debcedb82db239fa1aa8 to your computer and use it in GitHub Desktop.
Stock Lab

Stock Lab - 1.5hrs

You are going to create a simple Sinatra application that looks up Stock Exchange prices and returns the price to the user.

  1. Create a one page Sinatra app (just one route to "/").
  2. Use HTML and CSS to customise the layout.
  3. Add a form with a field for the stock symbol, and a button to submit.
  4. After the form is submitted, display to the user the stock symbol and the current price (retrieved from the internet using a Ruby gem -- you'll need to find one).

Some example stock symbols are:

Symbol Company Example Price
AAPL Apple 116.47
GOOG Google 537.5
AMZN Amazon 332.63
MSFT Microsoft 47.98
CAKE Cheesecake Factory Inc 47.27
FIZZ National Beverage Corp. 25.55
TSLA Tesla Motors 242.78
GPRO GoPro Inc. 70.72

Yahoo Finance gem

  # terminal
  gem install yahoofinance
  # ruby
  require 'yahoofinance'

  def get_standard_quotes(symbol)
    YahooFinance::get_standard_quotes(symbol)[symbol] rescue nil
  end

  stock = get_standard_quotes("aapl")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment