thirteen_f 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: faa86b34f746b8c24e08c909422945e7d16c1fc970532f0ed47b030484f3c75b
4
+ data.tar.gz: 2f6bea3847ab8ae71d4ad93935935f736b3f6aa2dbf7857ebc3ddd118d6f46cc
5
+ SHA512:
6
+ metadata.gz: bae8ed73b154e06568f55d4debeef353dc67bf5dfef321f52a9a42c126177ed4ebcd92fa21e6eb0c2fdf307258b5d02faa8c09965a895de6d37e8e352b2f8b71
7
+ data.tar.gz: 876b5c9291b0845f14932e36143c9e5d19f5dc723a826975a0fceb390421d8ce4a522b78891ca87394b5b4a403543e5274a6719ee798d864e9b3228c1f2e0713
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ /vendor/
11
+ Gemfile.lock
12
+
13
+ .gemrc
14
+
15
+ *.swp
16
+ *.swo
17
+
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at fordfischer07@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in thirteen_f.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ thirteen_f (0.1.0)
5
+ http (>= 4.4)
6
+ nokogiri
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ coderay (1.1.2)
14
+ domain_name (0.5.20190701)
15
+ unf (>= 0.0.5, < 1.0.0)
16
+ ffi (1.12.2)
17
+ ffi-compiler (1.0.1)
18
+ ffi (>= 1.0.0)
19
+ rake
20
+ http (4.4.0)
21
+ addressable (~> 2.3)
22
+ http-cookie (~> 1.0)
23
+ http-form_data (~> 2.2)
24
+ http-parser (~> 1.2.0)
25
+ http-cookie (1.0.3)
26
+ domain_name (~> 0.5)
27
+ http-form_data (2.3.0)
28
+ http-parser (1.2.1)
29
+ ffi-compiler (>= 1.0, < 2.0)
30
+ method_source (1.0.0)
31
+ mini_portile2 (2.4.0)
32
+ minitest (5.14.0)
33
+ nokogiri (1.10.9)
34
+ mini_portile2 (~> 2.4.0)
35
+ pry (0.13.0)
36
+ coderay (~> 1.1)
37
+ method_source (~> 1.0)
38
+ public_suffix (4.0.3)
39
+ rake (12.3.3)
40
+ unf (0.1.4)
41
+ unf_ext
42
+ unf_ext (0.0.7.6)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ minitest (~> 5.0)
49
+ pry
50
+ rake (~> 12.0)
51
+ thirteen_f!
52
+
53
+ BUNDLED WITH
54
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 fordfischer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # ThirteenF
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/thirteen_f`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'thirteen_f'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install thirteen_f
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/thirteen_f. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/thirteen_f/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
+
42
+ ## Code of Conduct
43
+
44
+ Everyone interacting in the ThirteenF project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/thirteen_f/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "thirteen_f"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'http'
4
+
5
+ class ThirteenF
6
+ class Company
7
+ attr_reader :cik, :name, :state_or_country
8
+
9
+ BASE_URL = 'https://www.sec.gov'
10
+
11
+ def self.from_sec_search_rows(rows)
12
+ rows.map do |row|
13
+ raise "Bad row" unless row.search('td').count == 3
14
+ cells = row.search('td')
15
+ cik = cells.first.text
16
+ name = parse_name cells[1]
17
+ state_or_country = cells.last.text
18
+ new cik, name, state_or_country
19
+ end
20
+ end
21
+
22
+ def self.from_company_page(page)
23
+ arr = page.search('.companyName').text.split('CIK#:')
24
+ name = arr.first.strip
25
+ cik = arr.last.strip.split(' ').first
26
+ state_or_country = page.search('.identInfo a').first.text
27
+ Array.new 1, new(cik, name, state_or_country)
28
+ end
29
+
30
+ def initialize(cik, name, state_or_country)
31
+ @cik = cik
32
+ @name = name
33
+ @state_or_country = state_or_country
34
+ true
35
+ end
36
+
37
+ def sec_filings_page_url
38
+ "#{BASE_URL}/cgi-bin/browse-edgar?CIK=#{cik}"
39
+ end
40
+
41
+ def thirteen_f_filings_url(count: 100)
42
+ "#{sec_filings_page_url}&type=13f&count=#{count}"
43
+ end
44
+
45
+ def get_links_to_filings
46
+ response = HTTP.get thirteen_f_filings_url
47
+ page = Nokogiri::HTML response.to_s
48
+ # compare these two - documents_button would be more direct
49
+ rows = page.search('table/tableFile2 > tr')[1..-1]
50
+ btns = page.search('#documentsbutton')
51
+ p [rows.count, btns.count]
52
+ end
53
+
54
+ private
55
+ def self.parse_name(name_cell)
56
+ name_cell.text.split("\n").first
57
+ end
58
+ end
59
+ end
60
+
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'http'
4
+
5
+ class ThirteenF
6
+ class Filing
7
+ def initialize
8
+ true
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'http'
4
+ require 'nokogiri'
5
+ require 'pry'
6
+
7
+ class ThirteenF
8
+ class Search
9
+ attr_reader :companies, :search_params
10
+
11
+ BASE_URL = 'https://www.sec.gov'
12
+ SEARCH_URL = "#{BASE_URL}/cgi-bin/browse-edgar"
13
+
14
+ def initialize(search_string, count: 100)
15
+ @search_params = [SEARCH_URL, params: {
16
+ company: search_string,
17
+ count: count
18
+ }]
19
+ end
20
+
21
+ def get_companies
22
+ response = HTTP.get(*search_params)
23
+ if response.status == 200
24
+ @companies = configure_search_results response
25
+ else
26
+ raise 'SEC results are not available right now'
27
+ end
28
+
29
+ end
30
+
31
+ private
32
+ def configure_search_results(response)
33
+ page = Nokogiri::HTML response.to_s
34
+ company_rows = page.search('table.tableFile2 > tr')[1..-1]
35
+ column_count = company_rows.first.search('td').count
36
+ if column_count == 3
37
+ company_rows.search('br').each { |n| n.replace("\n") }
38
+ Company.from_sec_search_rows company_rows
39
+ elsif column_count == 5
40
+ Company.from_company_page page
41
+ end
42
+ end
43
+ end
44
+ end
45
+
@@ -0,0 +1,3 @@
1
+ class ThirteenF
2
+ VERSION = "0.1.0"
3
+ end
data/lib/thirteen_f.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thirteen_f/company"
4
+ require "thirteen_f/search"
5
+ require "thirteen_f/filing"
6
+ require "thirteen_f/version"
7
+
8
+ class ThirteenF
9
+
10
+ class Error < StandardError; end
11
+
12
+ end
13
+
@@ -0,0 +1,41 @@
1
+ require_relative 'lib/thirteen_f/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "thirteen_f"
5
+ spec.version = ThirteenF::VERSION
6
+ spec.authors = ["fordfischer"]
7
+ spec.email = ["fordfischer07@gmail.com"]
8
+
9
+ spec.summary = %q{thirteen_f lets you easily interact with SEC 13-F
10
+ filing data in all the ways we think normal human beings might want to. The
11
+ SEC is the U.S. Securities and Exchange Commission. 13-F filings are
12
+ disclosures large investors in public securites have to provide and make
13
+ public every quarter.}
14
+
15
+ spec.description = %q{thirteen_f lets you easily interact with SEC 13-F
16
+ filing data in all the ways we think normal human beings might want to. The
17
+ SEC is the U.S. Securities and Exchange Commission. 13-F filings are
18
+ disclosures large investors in public securites have to provide and make
19
+ public every quarter.}
20
+ spec.homepage = "https://github.com/fordfischer/thirteen_f"
21
+ spec.license = "MIT"
22
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
23
+
24
+ spec.metadata["homepage_uri"] = spec.homepage
25
+ spec.metadata["source_code_uri"] = "https://github.com/fordfischer/thirteen_f"
26
+ spec.metadata["changelog_uri"] = "https://github.com/fordfischer/thirteen_f/commits/master"
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "minitest"
38
+ spec.add_development_dependency "pry"
39
+ spec.add_dependency "http", ">= 4.4"
40
+ spec.add_dependency "nokogiri"
41
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thirteen_f
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - fordfischer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: http
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '4.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '4.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |-
70
+ thirteen_f lets you easily interact with SEC 13-F
71
+ filing data in all the ways we think normal human beings might want to. The
72
+ SEC is the U.S. Securities and Exchange Commission. 13-F filings are
73
+ disclosures large investors in public securites have to provide and make
74
+ public every quarter.
75
+ email:
76
+ - fordfischer07@gmail.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - ".travis.yml"
83
+ - CODE_OF_CONDUCT.md
84
+ - Gemfile
85
+ - Gemfile.lock
86
+ - LICENSE.txt
87
+ - README.md
88
+ - Rakefile
89
+ - bin/console
90
+ - bin/setup
91
+ - lib/thirteen_f.rb
92
+ - lib/thirteen_f/company.rb
93
+ - lib/thirteen_f/filing.rb
94
+ - lib/thirteen_f/search.rb
95
+ - lib/thirteen_f/version.rb
96
+ - thirteen_f.gemspec
97
+ homepage: https://github.com/fordfischer/thirteen_f
98
+ licenses:
99
+ - MIT
100
+ metadata:
101
+ homepage_uri: https://github.com/fordfischer/thirteen_f
102
+ source_code_uri: https://github.com/fordfischer/thirteen_f
103
+ changelog_uri: https://github.com/fordfischer/thirteen_f/commits/master
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 2.5.0
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubygems_version: 3.1.2
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: thirteen_f lets you easily interact with SEC 13-F filing data in all the
123
+ ways we think normal human beings might want to. The SEC is the U.S. Securities
124
+ and Exchange Commission. 13-F filings are disclosures large investors in public
125
+ securites have to provide and make public every quarter.
126
+ test_files: []