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
Latest Entries
- Zip Code Distance Searching in Ruby on Rails
- Smart Searching Using Anonymous Scopes
- Yes, I started a dating site. I’m sorry.
- I’ve pulled a Brett Farve
- blog.john.yerhot.org
- Deployment Nightmare: Godaddy
- KVM, VMware, and my whole Saturday
- Henry Rollins at Sacred Heart
- Obligatory Google Chrome Post
- rQuote - Ruby on Rails Stock Quote Plugin
Aug 31st, 2008 at 1:26 pm
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.
Aug 31st, 2008 at 3:38 pm
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.
Oct 16th, 2008 at 9:39 am
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.
Oct 22nd, 2008 at 3:10 pm
@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!
Dec 29th, 2008 at 7:18 am
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?
Dec 31st, 2008 at 9:21 am
@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. (-: