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
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.
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.
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.
@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!
Hi John, thanks for the great plugin. I am checking it out this week. Yahoo doesn’t provide free real time commodity pricing, but they do for a fee.
If I have a fee-based account with Yahoo Finance, would rQuote work for real time commodity pricing through my account? Is there anything special I need to do, or should it work if I’m logged into my account?
@Johnny
No, it will not work with your fee based account.. I suppose I could look into getting it too, but I’m not sure I’ll have time to any time soon. (-: