sp500 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/sp500.rb +18 -17
- data/lib/sp500/stock.rb +7 -0
- data/lib/sp500/version.rb +1 -1
- data/lib/tools/hash_constructed.rb +7 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a604d93c7141470e2ac20b578b80220babdc1738a0dd26f6d5c9144683d9a28
|
4
|
+
data.tar.gz: b62df39d1ba51ee0722e440986e10c2b69284a44de5c32a650f9ac4e6e0ac0a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cadd84645d95ef8ac0bc5980da19e998d0020bcc1af25eb01a3a55fd7bd649ccb464a72622cd41213749508e60ab02ac093bafe69b3f194b2c67bf61cb61e4c8
|
7
|
+
data.tar.gz: 04dd5fcd88e26df60acea75572af624c71199b8f06582058fae950c8626af537228e51b5d591d6f705927757dfb1c571a5c7ac4bfff8ef2cad5727290aa7670b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/sp500.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'nokogiri'
|
3
|
-
require 'pp'
|
4
|
-
require 'byebug'
|
5
3
|
require 'date'
|
6
4
|
|
7
|
-
require "sp500/version"
|
8
5
|
require "tools/string_extensions"
|
6
|
+
require "tools/hash_constructed"
|
7
|
+
|
8
|
+
require "sp500/version"
|
9
|
+
require "sp500/stock"
|
9
10
|
|
10
11
|
module Sp500
|
11
12
|
using Tools::StringExtension
|
@@ -28,7 +29,7 @@ module Sp500
|
|
28
29
|
|
29
30
|
next if cells.empty?
|
30
31
|
|
31
|
-
|
32
|
+
Stock.new(
|
32
33
|
ticker_symbol: cells[0][0],
|
33
34
|
nyse_quote_url: cells[0][1],
|
34
35
|
firm_name: cells[1][0],
|
@@ -41,22 +42,22 @@ module Sp500
|
|
41
42
|
firm_hq_address_url: cells[5][1],
|
42
43
|
sp500_introduction_date: (cells[6].blank? ? 'n/a' : Date.parse(cells[6])),
|
43
44
|
central_index_key: cells[7]
|
44
|
-
|
45
|
+
)
|
45
46
|
end.compact
|
46
47
|
end
|
47
48
|
|
48
49
|
def sectors
|
49
|
-
list.map do |
|
50
|
-
|
50
|
+
list.map do |stock|
|
51
|
+
stock.gics_sector
|
51
52
|
end.uniq.sort
|
52
53
|
end
|
53
54
|
|
54
55
|
def industries
|
55
56
|
result = {}
|
56
57
|
|
57
|
-
list.each do |
|
58
|
-
result[
|
59
|
-
result[
|
58
|
+
list.each do |stock|
|
59
|
+
result[stock.gics_sector] ||= []
|
60
|
+
result[stock.gics_sector] << stock.gics_sub_industry unless result[stock.gics_sector].include?(stock.gics_sub_industry)
|
60
61
|
end
|
61
62
|
|
62
63
|
result
|
@@ -65,9 +66,9 @@ module Sp500
|
|
65
66
|
def by_sectors
|
66
67
|
result = {}
|
67
68
|
|
68
|
-
list.each do |
|
69
|
-
result[
|
70
|
-
result[
|
69
|
+
list.each do |stock|
|
70
|
+
result[stock.gics_sector] ||= []
|
71
|
+
result[stock.gics_sector] << stock
|
71
72
|
end
|
72
73
|
|
73
74
|
result
|
@@ -76,10 +77,10 @@ module Sp500
|
|
76
77
|
def by_industries
|
77
78
|
result = {}
|
78
79
|
|
79
|
-
list.each do |
|
80
|
-
result[
|
81
|
-
result[
|
82
|
-
result[
|
80
|
+
list.each do |stock|
|
81
|
+
result[stock.gics_sector] ||= {}
|
82
|
+
result[stock.gics_sector][stock.gics_sub_industry] ||= []
|
83
|
+
result[stock.gics_sector][stock.gics_sub_industry] << stock
|
83
84
|
end
|
84
85
|
|
85
86
|
result
|
data/lib/sp500/stock.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
module Sp500
|
2
|
+
class Stock
|
3
|
+
include Tools::HashConstructed
|
4
|
+
|
5
|
+
attr_accessor :ticker_symbol, :nyse_quote_url, :firm_name, :firm_wikipedia_url, :sec_filling_type, :sec_fillings_doc_url, :gics_sector, :gics_sub_industry, :firm_hq_address, :firm_hq_address_url, :sp500_introduction_date, :central_index_key
|
6
|
+
end
|
7
|
+
end
|
data/lib/sp500/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sp500
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Kifer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,7 +99,9 @@ files:
|
|
99
99
|
- bin/console
|
100
100
|
- bin/setup
|
101
101
|
- lib/sp500.rb
|
102
|
+
- lib/sp500/stock.rb
|
102
103
|
- lib/sp500/version.rb
|
104
|
+
- lib/tools/hash_constructed.rb
|
103
105
|
- lib/tools/string_extensions.rb
|
104
106
|
- sp500.gemspec
|
105
107
|
homepage: https://github.com/FranckyU/sp500
|