yahoo_finance_lib 0.6 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +8 -0
- data/README.md +10 -1
- data/lib/yahoo_finance/company_profile.rb +10 -2
- data/lib/yahoo_finance/stock.rb +19 -0
- data/lib/yahoo_finance/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d983b115acb96dd6eac3720ed79b1118f776444
|
4
|
+
data.tar.gz: c83f71a08f569cfbb5c7a08043d834a4ec87d362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c98697a3fe35489401b736aad6fedef4c677359656d904b0251530a74d40731d36af833f0ea63de2116478f0c2aa6553413b92eda37e733b210f22d3b5ab1c9d
|
7
|
+
data.tar.gz: b5b93dc9c7752c345390a971754c6eaa6ca868f1c216cfbf4b9d38bfb347c12de7e2142a073c4bda07a1edbdac602e4671fd5c78caeeb5d015ac05192f760a4a
|
data/History.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# History of changes
|
2
|
+
|
3
|
+
### Version 0.6
|
4
|
+
Original release, supporting key statistics, company events, and analyst opinion
|
5
|
+
### Version 0.7
|
6
|
+
Added company profile scraping :sector, and :industry
|
7
|
+
### Version 0.7.1
|
8
|
+
Added :website attribute in company profile; also added YahooFinance::StockHistory abstraction to nas/yahoo_finance
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
-
|
28
|
+
|
29
29
|
|
30
30
|
Example:
|
31
31
|
irb
|
@@ -41,6 +41,15 @@ Example:
|
|
41
41
|
results = stock.fetch
|
42
42
|
aapl_bid = results["AAPL"][:bid]
|
43
43
|
yhoo_last = results["YHOO"][:last_trade_price_only]
|
44
|
+
|
45
|
+
A simple interface using yahoo_stock to fetch history. It returns history as an array of hashes, e.g.
|
46
|
+
irb
|
47
|
+
require 'yahoo_finance'
|
48
|
+
require 'date'
|
49
|
+
|
50
|
+
start_date = Date.today - 30
|
51
|
+
history = YahooFinance::StockHistory.new('AAPL', start_date)
|
52
|
+
history.fetch
|
44
53
|
|
45
54
|
!-- ## Contributing
|
46
55
|
|
@@ -5,7 +5,8 @@ module YahooFinance
|
|
5
5
|
module CompanyProfile
|
6
6
|
COMPANY_PROFILE_STATS = {
|
7
7
|
:sector => ['Sector:', "Sector classification"],
|
8
|
-
:industry => ['Industry:', 'Industry classification']
|
8
|
+
:industry => ['Industry:', 'Industry classification'],
|
9
|
+
:website => ['Website:', 'Company website']
|
9
10
|
}
|
10
11
|
def CompanyProfile.key_events_available
|
11
12
|
return YahooFinance::CompanyProfile::COMPANY_PROFILE_STATS.keys;
|
@@ -24,9 +25,16 @@ module YahooFinance
|
|
24
25
|
@doc = Nokogiri::HTML(stream)
|
25
26
|
end
|
26
27
|
end
|
28
|
+
|
29
|
+
def doc
|
30
|
+
@doc
|
31
|
+
end
|
27
32
|
|
28
33
|
def value_for key_stat
|
29
|
-
if
|
34
|
+
if key_stat == :website
|
35
|
+
r = @doc.xpath("//td[contains(., \"#{YahooFinance::CompanyProfile::COMPANY_PROFILE_STATS[key_stat][0]}\")]")
|
36
|
+
return r.xpath("./a[contains(., 'http:')]").text
|
37
|
+
elsif CompanyProfile::key_events_available.include? key_stat
|
30
38
|
begin
|
31
39
|
value = @doc.xpath("//td[text() = \"#{YahooFinance::CompanyProfile::COMPANY_PROFILE_STATS[key_stat][0]}\"]")[0].parent.children[1].text
|
32
40
|
return value
|
data/lib/yahoo_finance/stock.rb
CHANGED
@@ -232,4 +232,23 @@ module YahooFinance
|
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|
235
|
+
|
236
|
+
class StockHistory
|
237
|
+
|
238
|
+
def initialize stock, start_date, end_date = nil
|
239
|
+
@stock = stock
|
240
|
+
@start_date = start_date
|
241
|
+
if end_date
|
242
|
+
@end_date = end_date
|
243
|
+
else
|
244
|
+
@end_date = Date.today - 1
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def fetch
|
249
|
+
ys = YahooStock::History.new(:stock_symbol => @stock, :start_date => @start_date, :end_date => @end_date)
|
250
|
+
ys.results(:to_hash).output
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
235
254
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yahoo_finance_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takis Mercouris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nas-yahoo_stock
|
@@ -108,6 +108,7 @@ extra_rdoc_files: []
|
|
108
108
|
files:
|
109
109
|
- .gitignore
|
110
110
|
- Gemfile
|
111
|
+
- History.md
|
111
112
|
- LICENSE.txt
|
112
113
|
- README.md
|
113
114
|
- Rakefile
|