yahoo_stock_splits 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +2 -0
- data/lib/yahoo_stock_splits/version.rb +3 -0
- data/lib/yahoo_stock_splits.rb +19 -0
- data/yahoo_stock_splits.gemspec +30 -0
- metadata +95 -0
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Javier Vidal
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= YahooStockSplits - Retrieve stock splits from Yahoo! Finance
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
YahooStockSplits retrieve stock splits from Yahoo! Finance. Split information is not available via CSV download, so
|
6
|
+
this gem scraps the basic chart page of the desired stock.
|
7
|
+
|
8
|
+
It returns an array of arrays that contains the date, post split shares, and pre split shares, in that order.
|
9
|
+
|
10
|
+
== Example
|
11
|
+
|
12
|
+
> YahooStockSplits.get("YHOO")
|
13
|
+
=> [["1997-09-02", 3, 2], ["1998-08-03", 2, 1], ["1999-02-08", 2, 1], ["2000-02-14", 2, 1], ["2004-05-12", 2, 1]]
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Javier Vidal. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module YahooStockSplits
|
2
|
+
|
3
|
+
require 'open-uri'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
def YahooStockSplits.get(symbol)
|
7
|
+
|
8
|
+
# Jul 3, 1989 [2:1]
|
9
|
+
re = /(.+)\[(\d+):(\d+)\]/
|
10
|
+
|
11
|
+
url = "http://finance.yahoo.com/q/bc?s=#{symbol}+Basic+Chart"
|
12
|
+
doc = Nokogiri::HTML(open(URI.parse(url)))
|
13
|
+
doc.css("center nobr").inject([]) do |splits, split|
|
14
|
+
md = re.match split
|
15
|
+
splits << [Date.parse(md[1]).strftime('%Y-%m-%d'), md[2].to_i, md[3].to_i] if md
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "yahoo_stock_splits/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "yahoo_stock_splits"
|
7
|
+
s.version = YahooStockSplits::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Javier Vidal"]
|
10
|
+
s.email = ["zanaguara@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/javiervidal/yahoo_stock_splits"
|
12
|
+
s.summary = %q{Retrieve stock splits from Yahoo! Finance}
|
13
|
+
s.description = <<END_OF_DESC
|
14
|
+
YahooStockSplits retrieve stock splits from Yahoo! Finance. Split information is not available via CSV download, so this gem scraps the basic chart page of the desired stock.
|
15
|
+
|
16
|
+
It returns an array of arrays that contains the date, post split shares, and pre split shares, in that order.
|
17
|
+
|
18
|
+
> YahooStockSplits.get("YHOO")
|
19
|
+
=> [["1997-09-02", 3, 2], ["1998-08-03", 2, 1], ["1999-02-08", 2, 1], ["2000-02-14", 2, 1], ["2004-05-12", 2, 1]]}
|
20
|
+
END_OF_DESC
|
21
|
+
|
22
|
+
s.rubyforge_project = "yahoo_stock_splits"
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
|
29
|
+
s.add_dependency('nokogiri')
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yahoo_stock_splits
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Javier Vidal
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-09-29 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: nokogiri
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: |
|
36
|
+
YahooStockSplits retrieve stock splits from Yahoo! Finance. Split information is not available via CSV download, so this gem scraps the basic chart page of the desired stock.
|
37
|
+
|
38
|
+
It returns an array of arrays that contains the date, post split shares, and pre split shares, in that order.
|
39
|
+
|
40
|
+
> YahooStockSplits.get("YHOO")
|
41
|
+
=> [["1997-09-02", 3, 2], ["1998-08-03", 2, 1], ["1999-02-08", 2, 1], ["2000-02-14", 2, 1], ["2004-05-12", 2, 1]]}
|
42
|
+
|
43
|
+
email:
|
44
|
+
- zanaguara@gmail.com
|
45
|
+
executables: []
|
46
|
+
|
47
|
+
extensions: []
|
48
|
+
|
49
|
+
extra_rdoc_files: []
|
50
|
+
|
51
|
+
files:
|
52
|
+
- .gitignore
|
53
|
+
- Gemfile
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.rdoc
|
56
|
+
- Rakefile
|
57
|
+
- lib/yahoo_stock_splits.rb
|
58
|
+
- lib/yahoo_stock_splits/version.rb
|
59
|
+
- yahoo_stock_splits.gemspec
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: https://github.com/javiervidal/yahoo_stock_splits
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: yahoo_stock_splits
|
90
|
+
rubygems_version: 1.3.7
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Retrieve stock splits from Yahoo! Finance
|
94
|
+
test_files: []
|
95
|
+
|