I merged some stock quoting stuff I had into a Rails plugin today. If you’d like to be able to simply grab real time stock quotes in your Rails app, this will do the job. Pretty much any stock symbol will work and you can enter as many as you’d like, you’ll get a hash array of hashes containing each symbol’s current value, change since open, and volume.

http://github.com/johnyerhot/rquote/tree/master

Rquote
======

Gets realtime stock quotes from Yahoo Finance. 

Its super simple to use.

Example
=======

quote = Rquote.new
quote.find("aapl", "msft") 

=> [{:change=>"-4.02", :price=>"169.72", :volume=>"16105013", :symbol=>"aapl"}, {:change=>"-0.42", :price=>"27.52",
:volume=>"27024456", :symbol=>"msft"}]

Copyright (c) 2008 John Yerhot, released under the MIT license

  1. Scott Motte

    This looks useful John. I am going to give this a look. I’ve been using the yahoofinance gem (http://rubyforge.org/projects/yahoofinance/), but your solution might be a bit cleaner.

  2. John

    Thanks Scott. Hope you do find it useful. The yahoo finance gem is going to provide you MUCH more functionality, but if all you need are stock quotes, this will get it done simpler.

  3. Marty

    Hi John,
    When using Rails 2.1.1 and Windows XP nothing is installed..

    C:\rails\demo\test>ruby script/plugin install git://github.com/johnyerhot/rquote.git

    returns:

    removing: c:/rails/demo/test/vendor/plugins/rquote/.git

    I have been Googling around but as I understand it should work without installing additional Git packages.

  4. John

    @Marty
    I’m on a Mac, so I’m not sure how much help I can give you. From the discussion on the Rails Weblog regarding Rails’ move to Git, it sounds like there are some other unhappy Windows users with the Rails community’s migration to Git…

    Anyways, I stumbled upon this which indicates that ruby script/plugin install http://github.com/johnyerhot/rquote.git will work. It also suggests installing Git with msysGit.

    Good luck!

Leave a Comment


To insert code, wrap in <pre></pre> tags.



Recommend Me

John Yerhot is Digg proof thanks to caching by WP Super Cache!