99c.org
Simple Ruby RBot stock lookup plugin
Posted on 11.04.07 by templeton @ 9:25 pm

Here is a quick plugin for the ruby rbot to do stock lookups in an IRC channel

command: stocks good yhoo tmta etc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# rbot yahoo stocks plugin
#
# version 0.1
# author: plochie ::@:: gmail.com
#
require 'rubygems'
require_gem 'yahoofinance'
 
class StocksPlugin < Plugin
 
  def help(plugin, topic="")
    return "stocks symbol1  symbol2 ..."
  end
 
  def lookup(m,params)
    symbols = params[:symbols].join(",")
 
    if symbols.length == 0
      m.reply "incorrect usage: " + help(m.plugin)
      return
    end
 
    YahooFinance::get_standard_quotes( symbols ).each do |symbol, qt|
      m.reply "#{qt.name} (#{symbol}) -> #{qt.lastTrade} Change: #{qt.change} Low: #{qt.dayLow} High: #{qt.dayHigh} Volume: #{qt.volume} "
    end
  end
end
# GOOG -> 457.37 -4.52 / Last Trade  N/A / Change  -0.98% / Min  457.24 / Max 457.37
 
plugin = StocksPlugin.new
plugin.map 'stocks *symbols', :action => 'lookup', :defaults => { :symbols => nil }


Filed under: Code
Comments:

1 Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>




Shorten URL




 Engadget

 Privacy


 Open Source


Recent Stories
» Apple cuts copy protection and prices on iTunes (AP)
» Apple disappoints: No Jobs or big news at Macworld (Reuters)
» Social Security unveils new online application (AP)
» Apple Unveils New MacBook Pro, Drops DRM for iTunes (NewsFactor)
» Apple disappoints--no Jobs or big news at Macworld (Reuters)
» Curl bolsters RIA data access (InfoWorld)
» Model wants Google to identify anonymous commenter (AP)
» Best Buy Offers Refurbished IPhones (PC World)
» Fake celeb LinkedIn profiles lead to malware (CNET)
» Truphone adds Skype, Twitter to iPhone client (CNET)
» Apple cuts copy protection and prices on iTunes (AP)
» Even in recession, CES to have stuff worth seeing (AP)
» Apple's Jobs has hormone imbalance, will stay CEO (AP)
» Logitech to cut salaried staff by 15 percent (AP)
» Fake celeb LinkedIn profiles lead to malware (CNET)