yahoo_finance 0.0.1 → 0.0.2
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.
- data/lib/yahoo_finance/historical.rb +4 -0
- data/lib/yahoo_finance/version.rb +1 -1
- data/spec/cassettes/AAPL-each.yml +42 -0
- data/spec/cassettes/AAPL-to_csv.yml +30 -0
- data/spec/historical_spec.rb +16 -0
- data/spec/spec_helper.rb +12 -0
- data/yahoo_finance.gemspec +2 -0
- metadata +31 -5
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://ichart.finance.yahoo.com:80/table.csv?s=AAPL&g=d&ignore=.csv&a=10&b=11&c=2011&d=10&e=21&f=2011
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 200
|
11
|
+
message: OK
|
12
|
+
headers:
|
13
|
+
date:
|
14
|
+
- Wed, 23 Nov 2011 12:33:37 GMT
|
15
|
+
p3p:
|
16
|
+
- policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
|
17
|
+
TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
|
18
|
+
ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
|
19
|
+
cache-control:
|
20
|
+
- private
|
21
|
+
transfer-encoding:
|
22
|
+
- chunked
|
23
|
+
content-type:
|
24
|
+
- text/csv
|
25
|
+
body: ! 'Date,Open,High,Low,Close,Volume,Adj Close
|
26
|
+
|
27
|
+
2011-11-21,370.40,371.68,365.91,369.01,15999300,369.01
|
28
|
+
|
29
|
+
2011-11-18,378.92,379.99,374.88,374.94,13283500,374.94
|
30
|
+
|
31
|
+
2011-11-17,383.98,384.58,375.50,377.41,17139300,377.41
|
32
|
+
|
33
|
+
2011-11-16,389.25,391.14,384.32,384.77,12449900,384.77
|
34
|
+
|
35
|
+
2011-11-15,380.80,389.50,379.45,388.83,15386100,388.83
|
36
|
+
|
37
|
+
2011-11-14,383.52,385.25,378.20,379.26,15460900,379.26
|
38
|
+
|
39
|
+
2011-11-11,386.61,388.70,380.26,384.62,23338400,384.62
|
40
|
+
|
41
|
+
'
|
42
|
+
http_version: '1.1'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://ichart.finance.yahoo.com:80/table.csv?s=AAPL&g=d&ignore=.csv&a=10&b=11&c=2011&d=10&e=11&f=2011
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 200
|
11
|
+
message: OK
|
12
|
+
headers:
|
13
|
+
date:
|
14
|
+
- Wed, 23 Nov 2011 12:34:12 GMT
|
15
|
+
p3p:
|
16
|
+
- policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
|
17
|
+
TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
|
18
|
+
ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
|
19
|
+
cache-control:
|
20
|
+
- private
|
21
|
+
transfer-encoding:
|
22
|
+
- chunked
|
23
|
+
content-type:
|
24
|
+
- text/csv
|
25
|
+
body: ! 'Date,Open,High,Low,Close,Volume,Adj Close
|
26
|
+
|
27
|
+
2011-11-11,386.61,388.70,380.26,384.62,23349500,384.62
|
28
|
+
|
29
|
+
'
|
30
|
+
http_version: '1.1'
|
data/spec/historical_spec.rb
CHANGED
@@ -33,6 +33,8 @@ describe YahooFinance::Historical do
|
|
33
33
|
describe "#each" do
|
34
34
|
subject { described_class.daily ticker, :from => start_date, :to => end_date }
|
35
35
|
|
36
|
+
use_vcr_cassette "AAPL-each"
|
37
|
+
|
36
38
|
it "iterates by ascending date order" do
|
37
39
|
subject.to_a.first.date.should < subject.to_a.last.date
|
38
40
|
end
|
@@ -47,4 +49,18 @@ describe YahooFinance::Historical do
|
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
52
|
+
|
53
|
+
describe "#to_csv" do
|
54
|
+
subject { described_class.daily(ticker, :from => Date.new(2011, 11, 11), :to => Date.new(2011, 11, 11)).to_csv }
|
55
|
+
|
56
|
+
use_vcr_cassette "AAPL-to_csv", :record => :once
|
57
|
+
|
58
|
+
it "returns the raw csv data" do
|
59
|
+
should match "2011-11-11,386.61,388.70,380.26,384.62,23349500,384.62"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "doesn't show the header row" do
|
63
|
+
should_not match "Date,Open,High,Low,Close,Volume,Adj Close"
|
64
|
+
end
|
65
|
+
end
|
50
66
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1,13 @@
|
|
1
1
|
require "yahoo_finance"
|
2
|
+
require "fakeweb"
|
3
|
+
require "vcr"
|
4
|
+
|
5
|
+
VCR.config do |c|
|
6
|
+
c.cassette_library_dir = File.expand_path("cassettes", File.dirname(__FILE__))
|
7
|
+
c.stub_with :fakeweb
|
8
|
+
c.default_cassette_options = { :record => :new_episodes }
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.configure do |c|
|
12
|
+
c.extend VCR::RSpec::Macros
|
13
|
+
end
|
data/yahoo_finance.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yahoo_finance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157307680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,29 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157307680
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: fakeweb
|
27
|
+
requirement: &2157306780 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2157306780
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: vcr
|
38
|
+
requirement: &2157306320 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2157306320
|
25
47
|
description: Simple wrapper for yahoo finance API
|
26
48
|
email:
|
27
49
|
- reu@rnavarro.com.br
|
@@ -35,6 +57,8 @@ files:
|
|
35
57
|
- lib/yahoo_finance.rb
|
36
58
|
- lib/yahoo_finance/historical.rb
|
37
59
|
- lib/yahoo_finance/version.rb
|
60
|
+
- spec/cassettes/AAPL-each.yml
|
61
|
+
- spec/cassettes/AAPL-to_csv.yml
|
38
62
|
- spec/historical_spec.rb
|
39
63
|
- spec/spec_helper.rb
|
40
64
|
- yahoo_finance.gemspec
|
@@ -52,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
76
|
version: '0'
|
53
77
|
segments:
|
54
78
|
- 0
|
55
|
-
hash:
|
79
|
+
hash: 255081617841847173
|
56
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
81
|
none: false
|
58
82
|
requirements:
|
@@ -61,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
85
|
version: '0'
|
62
86
|
segments:
|
63
87
|
- 0
|
64
|
-
hash:
|
88
|
+
hash: 255081617841847173
|
65
89
|
requirements: []
|
66
90
|
rubyforge_project: yahoo_finance
|
67
91
|
rubygems_version: 1.8.6
|
@@ -69,5 +93,7 @@ signing_key:
|
|
69
93
|
specification_version: 3
|
70
94
|
summary: Simple wrapper for yahoo finance API
|
71
95
|
test_files:
|
96
|
+
- spec/cassettes/AAPL-each.yml
|
97
|
+
- spec/cassettes/AAPL-to_csv.yml
|
72
98
|
- spec/historical_spec.rb
|
73
99
|
- spec/spec_helper.rb
|