Class: Edgar::Company
Overview
A company identified by ticker symbol, extending Entity with SEC lookup.
Instance Attribute Summary collapse
Attributes inherited from Entity
#cik
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Entity
#business_address, #company?, #data, #display_name, #get_filings, #individual?, #mailing_address, #name, #not_found?
Constructor Details
#initialize(cik: nil, ticker: nil) ⇒ Company
Returns a new instance of Company.
8
9
10
11
12
13
14
15
|
# File 'lib/edgar/company.rb', line 8
def initialize(cik: nil, ticker: nil)
if ticker
@ticker = ticker.upcase
cik ||= Company.lookup_cik(@ticker)
end
super(cik: cik)
end
|
Instance Attribute Details
#ticker ⇒ Object
Returns the value of attribute ticker.
6
7
8
|
# File 'lib/edgar/company.rb', line 6
def ticker
@ticker
end
|
Class Method Details
.clear_search_cache! ⇒ Object
192
193
194
|
# File 'lib/edgar/company.rb', line 192
def self.clear_search_cache!
@company_data_cache = nil
end
|
.lookup_cik(ticker) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/edgar/company.rb', line 144
def self.lookup_cik(ticker)
return @ticker_cache[ticker.upcase] if @ticker_cache&.key?(ticker.upcase)
data = load_company_data
mapping = {}
data.each do |entry|
t = entry[:ticker]
mapping[t] = entry[:cik]
end
cik = mapping[ticker.upcase]
(@ticker_cache ||= {})[ticker.upcase] = cik if cik
cik
end
|
.search(query, limit: 10) ⇒ Object
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/edgar/company.rb', line 160
def self.search(query, limit: 10)
return [] if query.nil? || query.strip.empty?
data = load_company_data
q = query.strip.downcase
matches = data.select do |entry|
entry[:ticker].downcase.include?(q) ||
entry[:title].downcase.include?(q)
end
matches.first(limit)
end
|
Instance Method Details
#annual_financials ⇒ Object
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/edgar/company.rb', line 82
def annual_financials
filing = latest_tenk
return Financials.(filing) if filing
%w[20-F 40-F].each do |form|
f = find_latest_filing_by_form(form)
return Financials.(f) if f
end
nil
end
|
#business_category ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/edgar/company.rb', line 103
def business_category
sic_str = sic.to_s
return "Bank" if %w[6021 6022 6035 6036].include?(sic_str)
return "Insurance Company" if %w[6311 6321 6331].include?(sic_str)
return "REIT" if sic_str == "6798"
et = data.entity_type.to_s.downcase
return "Investment Manager" if et.include?("investment")
return "Operating Company" if et == "operating"
"Operating Company"
end
|
#description ⇒ Object
53
54
55
|
# File 'lib/edgar/company.rb', line 53
def description
data.description
end
|
#exchanges ⇒ Object
25
26
27
|
# File 'lib/edgar/company.rb', line 25
def exchanges
data.exchanges
end
|
#facts ⇒ Object
70
71
72
|
# File 'lib/edgar/company.rb', line 70
def facts
@facts ||= EntityFacts.new(cik: @cik)
end
|
#filer_type ⇒ Object
132
133
134
135
136
137
|
# File 'lib/edgar/company.rb', line 132
def filer_type
return "Domestic" if state_of_incorporation == "CA"
return "Foreign" unless %w[CA DE FL IL MA MD NJ NY NV OH PA TX VA WA].include?(state_of_incorporation)
"Domestic"
end
|
#financial_institution? ⇒ Boolean
124
125
126
|
# File 'lib/edgar/company.rb', line 124
def financial_institution?
["Bank", "Insurance Company", "Investment Manager", "BDC"].include?(business_category)
end
|
#financials ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/edgar/company.rb', line 57
def financials
@financials ||= begin
filing = find_latest_filing_by_form("10-K") ||
find_latest_filing_by_form("20-F") ||
find_latest_filing_by_form("40-F")
if filing
Financials.(filing) || Financials.new(cik: @cik)
else
Financials.new(cik: @cik)
end
end
end
|
#fiscal_year_end ⇒ Object
37
38
39
|
# File 'lib/edgar/company.rb', line 37
def fiscal_year_end
data.fiscal_year_end
end
|
#foreign? ⇒ Boolean
128
129
130
|
# File 'lib/edgar/company.rb', line 128
def foreign?
%w[Foreign Canadian].include?(filer_type)
end
|
#fund? ⇒ Boolean
116
117
118
|
# File 'lib/edgar/company.rb', line 116
def fund?
["ETF", "Mutual Fund", "Closed-End Fund"].include?(business_category)
end
|
#industry ⇒ Object
33
34
35
|
# File 'lib/edgar/company.rb', line 33
def industry
data.sic_description
end
|
#latest_tenk ⇒ Object
74
75
76
|
# File 'lib/edgar/company.rb', line 74
def latest_tenk
find_latest_filing_by_form("10-K")
end
|
#latest_tenq ⇒ Object
78
79
80
|
# File 'lib/edgar/company.rb', line 78
def latest_tenq
find_latest_filing_by_form("10-Q")
end
|
#operating_company? ⇒ Boolean
120
121
122
|
# File 'lib/edgar/company.rb', line 120
def operating_company?
business_category == "Operating Company"
end
|
#phone ⇒ Object
45
46
47
|
# File 'lib/edgar/company.rb', line 45
def phone
data.phone
end
|
#primary_ticker ⇒ Object
21
22
23
|
# File 'lib/edgar/company.rb', line 21
def primary_ticker
tickers.first
end
|
#quarterly_financials ⇒ Object
93
94
95
96
97
98
99
100
101
|
# File 'lib/edgar/company.rb', line 93
def quarterly_financials
filing = latest_tenq
return Financials.(filing) if filing
filing = find_latest_filing_by_form("6-K")
return Financials.(filing) if filing
nil
end
|
#sic ⇒ Object
29
30
31
|
# File 'lib/edgar/company.rb', line 29
def sic
data.sic
end
|
#state_of_incorporation ⇒ Object
49
50
51
|
# File 'lib/edgar/company.rb', line 49
def state_of_incorporation
data.state_of_incorporation
end
|
#tickers ⇒ Object
17
18
19
|
# File 'lib/edgar/company.rb', line 17
def tickers
data.tickers
end
|
#to_s ⇒ Object
139
140
141
142
|
# File 'lib/edgar/company.rb', line 139
def to_s
ticker_str = @ticker || tickers.first
"#<Company #{ticker_str} (#{@cik})>"
end
|
#website ⇒ Object
41
42
43
|
# File 'lib/edgar/company.rb', line 41
def website
data.website
end
|