Permalink
Browse files

Fixed up Bloomberg (everything) and Yahoo (changes)

  • Loading branch information...
1 parent ae2e552 commit 09c296ccc47a06c9e86cd06bead23c9a3e3e59c2 @brymck committed Feb 19, 2012
Showing with 17 additions and 16 deletions.
  1. +2 −1 lib/rupee/quote.rb
  2. +12 −12 lib/rupee/source/bloomberg.rb
  3. +2 −2 lib/rupee/source/yahoo.rb
  4. +1 −1 lib/rupee/version.rb
View
@@ -64,7 +64,8 @@ def get(*params)
if now >= @next_pull
@next_pull = now + @frequency
@results = {}
- url = URI.parse(@source.url % ticker)
+ @ticker = "#{@ticker.to_s}:US" if @source == Source::BLOOMBERG && !@ticker.to_s.include?(":")
+ url = URI.parse(@source.url % @ticker)
res = Net::HTTP.start(url.host, url.port) do |http|
http.get url.request_uri
end
@@ -2,19 +2,19 @@ module Rupee
class Source
# Bloomberg
BLOOMBERG = Source.new(:bloomberg,
- "http://www.bloomberg.com/apps/quote?ticker=%s",
- :price => /(?:PRICE|VALUE): <span class="amount">([0-9.,NA-]{1,})/,
- :change => /Change<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/,
- :pct_chg => /Change<\/td>\n<td class="value[^>]+>[0-9.,NA-]{1,} \(([0-9NA.,-]{1,})\%/,
+ "http://www.bloomberg.com/quote/%s",
+ :price => /" price">\s*\n\s*([0-9,.-]+)/,
+ :change => /trending_[^>]+>([0-9NA.,-]+)/,
+ :pct_chg => /trending_[^>]+>[0-9NA.,-]+\s+<span>([0-9,.NA-]+)/,
:date => /"date">(.*?)</,
:time => /"time">(.*?)</,
- :bid => /Bid<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/,
- :ask => /Ask<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/,
- :open => /Open<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/,
- :high => /High<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/,
- :low => /Low<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/,
- :volume => /Volume<\/td>\n<td class="value[^>]+>([0-9.,NA-]{1,})/,
- :mkt_cap => /Market Cap[^<]+<\/td>\n<td class="value">([0-9.,NA-]{1,})/,
- :p_e => /Price\/Earnings[^<]+<\/td>\n<td class="value">([0-9.,NA-]{1,})/)
+ :bid => /Bid<\/td>\n<td class[^>]+>([0-9.,NA-]{1,})/,
+ :ask => /Ask<\/td>\n<td class[^>]+>([0-9.,NA-]{1,})/,
+ :open => /Open<\/td>\n<td class[^>]+>([0-9.,NA-]{1,})/,
+ :high => /High<\/td>\n<td class[^>]+>([0-9.,NA-]{1,})/,
+ :low => /Low<\/td>\n<td class[^>]+>([0-9.,NA-]{1,})/,
+ :volume => /Volume<\/td>\n<td class[^>]+>([0-9.,NA-]{1,})/,
+ :mkt_cap => /Market Cap[^<]+<\/td>\n<td class[^>]+">([0-9.,NA-]{1,})/,
+ :p_e => /Price\/Earnings[^<]+<\/td>\n<td class[^>]+>([0-9.,NA-]{1,})/)
end
end
@@ -3,8 +3,8 @@ class Source
YAHOO = Source.new(:yahoo,
"http://finance.yahoo.com/q?s=%s",
:price => /yfs_l84_[^>]+>([0-9,.-]+)/,
- :change => /yfs_c6[34]_[^>]+>(?:<img[^>]+>)\s*([0-9,.-])+/,
- :pct_chg => /yfs_p4[34]_[^>]+>\(([0-9,.-]+)%\)/,
+ :change => /yfs_c(?:6[34]|10)_[^>]+>(?:<img[^>]+>)\s*([0-9,.-])+/,
+ :pct_chg => /yfs_p(?:4[34]|20)_[^>]+>\(([0-9,.-]+)%\)/,
:date => /<span id="yfs_market_time">.*?, (.*?20[0-9]{1,2})/,
:time => /(?:"time"|"yfnc_tabledata1")><span id="yfs_t[51]0_[^>]+>(.*?)</,
:bid => /yfs_b00_[^>]+>([0-9,.-]{1,})/,
@@ -1,4 +1,4 @@
module Rupee
# The current version
- VERSION = "0.2.9"
+ VERSION = "0.2.9.1"
end

0 comments on commit 09c296c

Please sign in to comment.