Class: Rupee::Source
- Inherits:
-
Object
- Object
- Rupee::Source
- Extended by:
- FindInstance
- Defined in:
- lib/rupee/source.rb,
lib/rupee/source/yahoo.rb,
lib/rupee/source/google.rb,
lib/rupee/source/bloomberg.rb
Overview
A class to hold quote sources
Constant Summary collapse
- YAHOO =
Source.new(:yahoo, "http://finance.yahoo.com/q?s=%s", :price => /yfs_l(?:10|84)_[^>]+>([0-9,.-]+)/, :change => /yfs_c(?:6[034]|10)_[^>]+>(?:<img[^>]+>)\s*([0-9,.-]+)/, :pct_chg => /yfs_p(?:4[034]|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,})/, :ask => /yfs_a00_[^>]+>([0-9,.-]{1,})/, :open => /Open:<\/th><td class="yfnc_tabledata1">([0-9,.-]{1,})/, :high => /yfs_h53_[^>]+>([0-9,.-]{1,})/, :low => /yfs_g53_[^>]+>([0-9,.-]{1,})/, :volume => /yfs_v53_[^>]+>([0-9,.-]{1,})/, :mkt_cap => /yfs_j10_[^>]+>([0-9,.-]{1,}[KMBT]?)/)
- GOOGLE =
Google Finance
Source.new(:google, "http://www.google.com/ig/api?stock=%s", :price => /<last data="([0-9.-]*)"/, :change => /<change data="\+?([0-9.-]*)"/, :pct_chg => /<perc_change data="([0-9.-]*)"/, :date => /<trade_date_utc data="([0-9.-]*)"/, :time => /<trade_date_utc data="([0-9.-]*)"/, :open => /<open data="([0-9.-]*)"/, :high => /<high data="([0-9.-]*)"/, :low => /<low data="([0-9.-]*)"/, :volume => /<volume data="([0-9.-]*)"/, :mkt_cap => /<market_cap data="([0-9.-]*)"/)
- BLOOMBERG =
Bloomberg
Source.new(:bloomberg, "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:<\/th>\n\s*<td[^>]*>([0-9.,NA-]{1,})/, :ask => /Ask:<\/th>\n\s*<td[^>]*>([0-9.,NA-]{1,})/, :open => /Open:<\/th>\n\s*<td[^>]*>([0-9.,NA-]{1,})/, :high => /(?:Day(?:'s)? Range:<\/th>\n\s*<td[^>]*>[0-9.,NA-]+ - |High - Low:<\/th>\n\s*<td[^>]*>)([0-9.,NA-]+)/, :low => /(?:Day(?:'s)? Range:<\/th>\n\s*<td[^>]*>|High - Low:<\/th>\n\s*<td[^>]*>[0-9.,NA-]+ - )([0-9.,NA-]+)/, :volume => /Volume:<\/th>\n\s*<td class[^>]+>([0-9.,NA-]{1,})/, :mkt_cap => /Market Cap[^<]+<\/th>\n\s*<td[^>]*">([0-9.,NA-]{1,})/, :p_e => /Current P\/E[^<]+<\/th>\n\s*<td[^>]*>([0-9.,NA-]{1,})/)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the source.
-
#params ⇒ Object
readonly
The parameters available.
-
#url ⇒ Object
readonly
The full URL for where the security information is located, where
%s
is a query parameter.
Instance Method Summary collapse
-
#initialize(name, url, params = {}) ⇒ Source
constructor
Creates a new quote service.
Methods included from FindInstance
Constructor Details
#initialize(name, url, params = {}) ⇒ Source
Creates a new quote service
20 21 22 |
# File 'lib/rupee/source.rb', line 20 def initialize(name, url, params = {}) @name, @url, @params = name, url, params end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the source
12 13 14 |
# File 'lib/rupee/source.rb', line 12 def name @name end |
#params ⇒ Object (readonly)
The parameters available
17 18 19 |
# File 'lib/rupee/source.rb', line 17 def params @params end |
#url ⇒ Object (readonly)
The full URL for where the security information is located, where %s
is a query parameter
15 16 17 |
# File 'lib/rupee/source.rb', line 15 def url @url end |