securities 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +44 -6
- data/lib/securities/stock.rb +5 -0
- data/lib/securities/version.rb +1 -1
- data/securities.gemspec +2 -2
- metadata +6 -6
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Securities
|
2
2
|
|
3
|
-
|
3
|
+
Financial information scraper gem.
|
4
|
+
Uses Yahoo Finance API.
|
4
5
|
|
5
|
-
|
6
|
+
[![Build Status](https://secure.travis-ci.org/Nedomas/securities.png)](http://travis-ci.org/Nedomas/securities)[![Build Status](https://gemnasium.com/Nedomas/securities.png)](https://gemnasium.com/Nedomas/securities)
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -22,17 +23,54 @@ Or install it yourself as:
|
|
22
23
|
|
23
24
|
You can get stock information with commands:
|
24
25
|
|
25
|
-
|
26
|
+
# Comma seperated symbols
|
27
|
+
my_stocks = Securities::Stock.new('aapl', 'yhoo')
|
28
|
+
|
29
|
+
or
|
30
|
+
|
31
|
+
# Symbol array
|
32
|
+
my_stocks = Securities::Stock.new(["aapl", "yhoo"])
|
33
|
+
|
34
|
+
my_data = my_stocks.history(:start_date => '2012-01-01', :end_date => '2012-02-01', :periods => :weekly)
|
35
|
+
|
26
36
|
Optional parameter :periods accepts :daily, :weekly, :monthly, :dividend. If not specified, it defaults to :daily.
|
27
37
|
|
28
38
|
You can access hash for a single stock with:
|
29
39
|
|
30
|
-
|
40
|
+
my_data.results["yhoo"]
|
31
41
|
|
32
42
|
Results are returned in a hash:
|
33
43
|
|
34
|
-
{"aapl"=>
|
35
|
-
|
44
|
+
{"aapl"=>
|
45
|
+
[{:date=>"2012-01-04",
|
46
|
+
:open=>"410.00",
|
47
|
+
:high=>"414.68",
|
48
|
+
:low=>"409.28",
|
49
|
+
:close=>"413.44",
|
50
|
+
:volume=>"9286500",
|
51
|
+
:adj_close=>"411.67"},
|
52
|
+
{:date=>"2012-01-03",
|
53
|
+
:open=>"409.40",
|
54
|
+
:high=>"412.50",
|
55
|
+
:low=>"409.00",
|
56
|
+
:close=>"411.23",
|
57
|
+
:volume=>"10793600",
|
58
|
+
:adj_close=>"409.47"}],
|
59
|
+
"yhoo"=>
|
60
|
+
[{:date=>"2012-01-04",
|
61
|
+
:open=>"16.12",
|
62
|
+
:high=>"16.16",
|
63
|
+
:low=>"15.74",
|
64
|
+
:close=>"15.78",
|
65
|
+
:volume=>"35655300",
|
66
|
+
:adj_close=>"15.78"},
|
67
|
+
{:date=>"2012-01-03",
|
68
|
+
:open=>"16.27",
|
69
|
+
:high=>"16.39",
|
70
|
+
:low=>"16.20",
|
71
|
+
:close=>"16.29",
|
72
|
+
:volume=>"19708600",
|
73
|
+
:adj_close=>"16.29"}]}
|
36
74
|
|
37
75
|
## To do:
|
38
76
|
|
data/lib/securities/stock.rb
CHANGED
@@ -88,6 +88,7 @@ module Securities
|
|
88
88
|
# Input parameters validation
|
89
89
|
#
|
90
90
|
def validate_symbols parameters
|
91
|
+
|
91
92
|
# Reject empty symbol hashes.
|
92
93
|
@symbols = parameters.reject(&:empty?)
|
93
94
|
|
@@ -95,6 +96,10 @@ module Securities
|
|
95
96
|
raise StockException, 'You must specify stock symbols.'
|
96
97
|
end
|
97
98
|
|
99
|
+
# FIXME: A kinda hacky way to check if parameters are a nested array (when accepting an array as a symbols argument).
|
100
|
+
# Unnesting an array.
|
101
|
+
@symbols[0].is_a?(Array) ? @symbols = @symbols[0] : nil
|
102
|
+
|
98
103
|
unless @symbols.uniq.length == @symbols.length
|
99
104
|
raise StockException, 'Duplicate symbols given.'
|
100
105
|
end
|
data/lib/securities/version.rb
CHANGED
data/securities.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/securities/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Nedomas"]
|
6
6
|
gem.email = ["domas.bitvinskas@me.com"]
|
7
|
-
gem.description = %q{Financial information scraper
|
8
|
-
gem.summary = %q{Financial information scraper
|
7
|
+
gem.description = %q{Financial information scraper gem. Uses Yahoo Finance API.}
|
8
|
+
gem.summary = %q{Financial information scraper gem. Uses Yahoo Finance API.}
|
9
9
|
gem.homepage = "https://github.com/Nedomas/securities"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: securities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description: Financial information scraper
|
46
|
+
description: Financial information scraper gem. Uses Yahoo Finance API.
|
47
47
|
email:
|
48
48
|
- domas.bitvinskas@me.com
|
49
49
|
executables: []
|
@@ -78,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
segments:
|
80
80
|
- 0
|
81
|
-
hash:
|
81
|
+
hash: 4396400797512649668
|
82
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
@@ -87,13 +87,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
segments:
|
89
89
|
- 0
|
90
|
-
hash:
|
90
|
+
hash: 4396400797512649668
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
93
|
rubygems_version: 1.8.23
|
94
94
|
signing_key:
|
95
95
|
specification_version: 3
|
96
|
-
summary: Financial information scraper
|
96
|
+
summary: Financial information scraper gem. Uses Yahoo Finance API.
|
97
97
|
test_files:
|
98
98
|
- spec/securities_spec.rb
|
99
99
|
- spec/spec_helper.rb
|