sec_edgar 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sec_edgar/entity.rb +2 -29
- data/lib/sec_edgar/filing.rb +5 -16
- data/lib/sec_edgar/filing_parser.rb +6 -6
- data/lib/sec_edgar.rb +0 -1
- metadata +1 -3
- data/lib/sec_edgar/filing_persister.rb +0 -53
- data/lib/sec_edgar/filing_updater.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bb5d593362ef06b85a4a1f7c05b418ee4cc79a6
|
4
|
+
data.tar.gz: f34e996d9f8b8b53272a9702c7e07f5b81b0700c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f6edfe37d12ea5470e8a879ff4421e6f907cc940d03728e6ad578ec4c26c490d742d1e3c53f64acadef457e015a950e0b9dca6765d33c3b505b103f82a68a7e
|
7
|
+
data.tar.gz: d186ec0b42a1f43d4c5d23b352f34f2092314570ccd6b334266a4ea9405baca3cc5bc6f91df003388a7b55485c4fdcd36053bfda5ef6da3178c8081004123a92
|
data/lib/sec_edgar/entity.rb
CHANGED
@@ -26,11 +26,11 @@ module SecEdgar
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def filings
|
29
|
-
Filing.find(@cik)
|
29
|
+
SecEdgar::Filing.find(@cik)
|
30
30
|
end
|
31
31
|
|
32
32
|
def transactions
|
33
|
-
Transaction.find(@cik)
|
33
|
+
SecEdgar::Transaction.find(@cik)
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.query(url)
|
@@ -43,32 +43,5 @@ module SecEdgar
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
|
-
# def self.find(entity_args)
|
48
|
-
# temp = {}
|
49
|
-
# temp[:url] = SecURI.browse_edgar_uri(entity_args)
|
50
|
-
# temp[:url][:action] = :getcompany
|
51
|
-
# response = query(temp[:url].output_atom.to_s)
|
52
|
-
# document = Nokogiri::HTML(response)
|
53
|
-
# xml = document.xpath("//feed/company-info")
|
54
|
-
# Entity.new(parse(xml))
|
55
|
-
# end
|
56
|
-
#
|
57
|
-
# def self.parse(xml)
|
58
|
-
# content = Hash.from_xml(xml.to_s)
|
59
|
-
# if content['company_info'].present?
|
60
|
-
# content = content['company_info']
|
61
|
-
# content['name'] = content.delete('conformed_name')
|
62
|
-
# if content['formerly_names'].present?
|
63
|
-
# content['formerly_names'] = content.delete('formerly_names')['names']
|
64
|
-
# end
|
65
|
-
# content['addresses']['address'].each do |address|
|
66
|
-
# content["#{address['type']}_address"] = address
|
67
|
-
# end
|
68
|
-
# return content
|
69
|
-
# else
|
70
|
-
# return {}
|
71
|
-
# end
|
72
|
-
# end
|
73
46
|
end
|
74
47
|
end
|
data/lib/sec_edgar/filing.rb
CHANGED
@@ -82,7 +82,7 @@ module SecEdgar
|
|
82
82
|
unless data[4][0..3] == 'http'
|
83
83
|
data[4] = "http://www.sec.gov/Archives/#{ data[4] }"
|
84
84
|
end
|
85
|
-
Filing.new(
|
85
|
+
SecEdgar::Filing.new(
|
86
86
|
term: data[1],
|
87
87
|
cik: data[2],
|
88
88
|
date: Date.parse(data[3]),
|
@@ -91,7 +91,7 @@ module SecEdgar
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def self.uri_for_recent(start = 0, count = 100)
|
94
|
-
SecURI.browse_edgar_uri(
|
94
|
+
SecEdgar::SecURI.browse_edgar_uri(
|
95
95
|
action: :getcurrent,
|
96
96
|
owner: :include,
|
97
97
|
output: :atom,
|
@@ -101,7 +101,7 @@ module SecEdgar
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def self.uri_for_cik(cik, start = 0, count = 100)
|
104
|
-
SecURI.browse_edgar_uri(
|
104
|
+
SecEdgar::SecURI.browse_edgar_uri(
|
105
105
|
action: :getcompany,
|
106
106
|
owner: :include,
|
107
107
|
output: :atom,
|
@@ -114,7 +114,7 @@ module SecEdgar
|
|
114
114
|
def self.parse_rss(rss, &blk)
|
115
115
|
feed = RSS::Parser.parse(rss, false)
|
116
116
|
feed.entries.each do |entry|
|
117
|
-
filing = Filing.new(
|
117
|
+
filing = SecEdgar::Filing.new(
|
118
118
|
cik: entry.title.content.match(/\((\w{10})\)/)[1],
|
119
119
|
file_id: entry.id.content.split('=').last,
|
120
120
|
term: entry.category.term,
|
@@ -127,17 +127,6 @@ module SecEdgar
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
# def self.find(cik, start = 0, count = 80)
|
131
|
-
# temp = {}
|
132
|
-
# temp[:url] = SecURI.browse_edgar_uri({cik: cik})
|
133
|
-
# temp[:url][:action] = :getcompany
|
134
|
-
# temp[:url][:start] = start
|
135
|
-
# temp[:url][:count] = count
|
136
|
-
# response = Entity.query(temp[:url].output_atom.to_s)
|
137
|
-
# document = Nokogiri::HTML(response)
|
138
|
-
# parse(cik, document)
|
139
|
-
# end
|
140
|
-
|
141
130
|
def self.parse(cik, document)
|
142
131
|
filings = []
|
143
132
|
if document.xpath('//content').to_s.length > 0
|
@@ -150,7 +139,7 @@ module SecEdgar
|
|
150
139
|
content[:link] = content.delete('filing_href')
|
151
140
|
content[:term] = content.delete('filing_type')
|
152
141
|
content[:title] = content.delete('form_name')
|
153
|
-
filings << Filing.new(content)
|
142
|
+
filings << SecEdgar::Filing.new(content)
|
154
143
|
end
|
155
144
|
end
|
156
145
|
end
|
@@ -16,14 +16,14 @@ module SecEdgar
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def doc
|
19
|
-
@doc ||= ::OwnershipDocument.new
|
19
|
+
@doc ||= SecEdgar::OwnershipDocument.new
|
20
20
|
end
|
21
21
|
|
22
22
|
def parse(&error_blk)
|
23
23
|
if block_given? && !xml_valid?
|
24
24
|
error_blk.call(xml_errors)
|
25
25
|
puts "Error: returning NilObjectDocument #{ @filing.link }"
|
26
|
-
return ::NilOwnershipDocument.new
|
26
|
+
return SecEdgar::NilOwnershipDocument.new
|
27
27
|
end
|
28
28
|
|
29
29
|
footnotes | transactions | derivative_transactions # eager init
|
@@ -62,7 +62,7 @@ module SecEdgar
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def parse_transaction(el)
|
65
|
-
transaction = Transaction.new
|
65
|
+
transaction = SecEdgar::Transaction.new
|
66
66
|
transaction.security_title = el.xpath('securityTitle').text.strip
|
67
67
|
transaction.transaction_date = Date.parse(el.xpath('transactionDate').text)
|
68
68
|
|
@@ -79,14 +79,14 @@ module SecEdgar
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def parse_footnote(el)
|
82
|
-
footnote = Footnote.new
|
82
|
+
footnote = SecEdgar::Footnote.new
|
83
83
|
footnote.content = el.text.strip
|
84
84
|
footnote.id = el.attribute("id").value
|
85
85
|
footnotes << footnote
|
86
86
|
end
|
87
87
|
|
88
88
|
def parse_derivative_transaction(el)
|
89
|
-
transaction = DerivativeTransaction.new
|
89
|
+
transaction = SecEdgar::DerivativeTransaction.new
|
90
90
|
|
91
91
|
transaction.security_title = el.xpath('securityTitle').text.strip
|
92
92
|
transaction.transaction_date = Date.parse(el.xpath('transactionDate').text)
|
@@ -187,7 +187,7 @@ module SecEdgar
|
|
187
187
|
el.xpath('//isOfficer').text.downcase == 'true')
|
188
188
|
doc.officer_title = el.xpath('//officerTitle').text
|
189
189
|
|
190
|
-
address = ::Address.new
|
190
|
+
address = SecEdgar::Address.new
|
191
191
|
address.street1 = el.xpath('//rptOwnerStreet1').text
|
192
192
|
address.street2 = el.xpath('//rptOwnerStreet2').text
|
193
193
|
address.city = el.xpath('//rptOwnerCity').text
|
data/lib/sec_edgar.rb
CHANGED
@@ -19,7 +19,6 @@ require_relative './sec_edgar/filing'
|
|
19
19
|
require_relative './sec_edgar/footnote'
|
20
20
|
require_relative './sec_edgar/derivative_transaction'
|
21
21
|
require_relative './sec_edgar/transaction'
|
22
|
-
require_relative './sec_edgar/filing_persister'
|
23
22
|
require_relative './sec_edgar/filing_parser'
|
24
23
|
require_relative './sec_edgar/officer_title'
|
25
24
|
require_relative './sec_edgar/ownership_document'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sec_edgar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CJ Avilla
|
@@ -83,8 +83,6 @@ files:
|
|
83
83
|
- lib/sec_edgar/entity.rb
|
84
84
|
- lib/sec_edgar/filing.rb
|
85
85
|
- lib/sec_edgar/filing_parser.rb
|
86
|
-
- lib/sec_edgar/filing_persister.rb
|
87
|
-
- lib/sec_edgar/filing_updater.rb
|
88
86
|
- lib/sec_edgar/footnote.rb
|
89
87
|
- lib/sec_edgar/ftp_client.rb
|
90
88
|
- lib/sec_edgar/nil_ownership_document.rb
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# module SecEdgar
|
2
|
-
# class FilingPersister
|
3
|
-
# attr_reader :filing
|
4
|
-
#
|
5
|
-
# def initialize(filing)
|
6
|
-
# @filing = filing
|
7
|
-
# end
|
8
|
-
#
|
9
|
-
# def doc
|
10
|
-
# @doc ||= RawFiling.for_filing(filing).parsed
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# def persist!
|
14
|
-
# return form if form = Form4.find_by(link: filing.link)
|
15
|
-
# doc_json = doc.to_json
|
16
|
-
# return if doc_json == '{}'
|
17
|
-
#
|
18
|
-
# form = Form4.new(
|
19
|
-
# cik: filing.cik,
|
20
|
-
# title: filing.title,
|
21
|
-
# link: filing.link,
|
22
|
-
# term: filing.term,
|
23
|
-
# date: filing.date,
|
24
|
-
# file_id: filing.file_id,
|
25
|
-
# dollar_volume: doc.dollar_volume,
|
26
|
-
# document: { d: doc_json }
|
27
|
-
# )
|
28
|
-
# form.company = Company.where(cik: doc.issuer_cik).first_or_initialize
|
29
|
-
# form.company.update_attributes(
|
30
|
-
# name: doc.issuer_name,
|
31
|
-
# ticker: doc.issuer_trading_symbol.upcase
|
32
|
-
# )
|
33
|
-
#
|
34
|
-
# form.insider = Insider.where(cik: doc.owner_cik).first_or_initialize
|
35
|
-
# form.insider.update_attributes(
|
36
|
-
# name: doc.owner_name[0, 254]
|
37
|
-
# )
|
38
|
-
#
|
39
|
-
# form.day_traded_price = form.company.price_on(form.date)
|
40
|
-
# form.day_traded_volume = form.company.volume_on(form.date)
|
41
|
-
# form.plus_3_months_price = form.company.price_on(form.date + 3.months)
|
42
|
-
# form.plus_6_months_price = form.company.price_on(form.date + 6.months)
|
43
|
-
# form.plus_12_months_price = form.company.price_on(form.date + 12.months)
|
44
|
-
# # need to find a more detailed data source
|
45
|
-
# # form.price_to_earnings = Company.price_to_earnings_on(form.date)
|
46
|
-
# # form.price_to_book = Company.price_to_book_on(form.date)
|
47
|
-
#
|
48
|
-
# form.doc = doc
|
49
|
-
# form.save!
|
50
|
-
# form
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
# end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module SecEdgar
|
2
|
-
class FilingUpdater
|
3
|
-
attr_reader :form
|
4
|
-
|
5
|
-
def initialize(form)
|
6
|
-
@form = form
|
7
|
-
end
|
8
|
-
|
9
|
-
def doc
|
10
|
-
@doc ||= RawFiling.for_form(form).parsed
|
11
|
-
end
|
12
|
-
|
13
|
-
def update
|
14
|
-
doc_json = doc.to_json
|
15
|
-
return if doc_json == '{}'
|
16
|
-
|
17
|
-
form.update({
|
18
|
-
dollar_volume: doc.dollar_volume,
|
19
|
-
document: { d: doc_json }
|
20
|
-
})
|
21
|
-
|
22
|
-
unless form.company
|
23
|
-
form.company = Company.where(cik: doc.issuer_cik).first_or_initialize
|
24
|
-
form.company.update_attributes(
|
25
|
-
name: doc.issuer_name,
|
26
|
-
ticker: doc.issuer_trading_symbol.upcase
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
unless form.insider
|
31
|
-
form.insider = Insider.where(cik: doc.owner_cik).first_or_initialize
|
32
|
-
form.insider.update_attributes(
|
33
|
-
name: doc.owner_name[0, 254]
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
dt = Date.parse(form.date)
|
38
|
-
form.day_traded_price = form.company.price_on(dt)
|
39
|
-
form.day_traded_volume = form.company.volume_on(dt)
|
40
|
-
form.plus_3_months_price = form.company.price_on(dt + 3.months)
|
41
|
-
form.plus_6_months_price = form.company.price_on(dt + 6.months)
|
42
|
-
form.plus_12_months_price = form.company.price_on(dt + 12.months)
|
43
|
-
# need to find a more detailed data source
|
44
|
-
# form.price_to_earnings = Company.price_to_earnings_on(form.date)
|
45
|
-
# form.price_to_book = Company.price_to_book_on(form.date)
|
46
|
-
|
47
|
-
form.doc = doc
|
48
|
-
form.save!
|
49
|
-
form
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|