thirteen_f 0.5.7 → 0.5.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df77325327b6f6e94962f5ace93666fabe2d51daca208a13cf28509c32ab7a86
4
- data.tar.gz: 19928c22e77651f3913a193c10853a2fd8e5a7c0bd958a1540b190899de174a9
3
+ metadata.gz: 369e8186185983d60f194d55ddddd7dbd46d12d9e981023e5ed7043b090a6115
4
+ data.tar.gz: 5d0a4e7108e254484cb2d1c86a0c2a6a011e29619fcf1f6cb1c3f6cab53027f8
5
5
  SHA512:
6
- metadata.gz: 2e91220848bd2f7d3776a9f14e35e43f0faa893a9f94b59e02ac8c2ea505177dbae2299615f097ce1cb31165664dfa75ae097142bbe65f68739f854a315ef0e8
7
- data.tar.gz: 4bf2e3b11750597bd5c5878cf20af2c9a18003af9de2ab7a360353cde5724ca4a96e0834181e035e3df69170d64f35ac2a1a8ea2469cafc22a8c8832d29317ae
6
+ metadata.gz: c7f33972184bab82574256bf799581a2fbc87c8c9f8a02076345d45d0934d189812fc6b8df9905ab3474d6a2582470400e85cc985cd9b28c75d0eb60984e62cb
7
+ data.tar.gz: 7a36382d29fc2a22a2535578debfd34fb35755d94333ee973402808b4fd87078673d3d006d994cfa75545f3d97a43729aae9e485d080526b4f78a7b3bfaa5e11
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thirteen_f (0.5.7)
4
+ thirteen_f (0.5.9)
5
5
  http (>= 5.1)
6
6
  nokogiri (>= 1.15)
7
7
  pdf-reader (>= 2.11)
@@ -32,8 +32,10 @@ GEM
32
32
  ffi-compiler (~> 1.0)
33
33
  rake (~> 13.0)
34
34
  method_source (1.0.0)
35
+ mini_portile2 (2.8.5)
35
36
  minitest (5.20.0)
36
- nokogiri (1.15.5-arm64-darwin)
37
+ nokogiri (1.15.5)
38
+ mini_portile2 (~> 2.8.2)
37
39
  racc (~> 1.4)
38
40
  pdf-reader (2.11.0)
39
41
  Ascii85 (~> 1.0)
@@ -37,7 +37,11 @@ class ThirteenF
37
37
 
38
38
  def get_list_entries
39
39
  return false unless file_location
40
- io = URI.open file_location
40
+ io = URI.open(
41
+ file_location,
42
+ 'User-Agent' => "ThirteenF/v#{::ThirteenF::VERSION} (Open Source Ruby Gem) savannah.fischer@hey.com",
43
+ 'Host' => 'www.sec.gov'
44
+ )
41
45
  reader = PDF::Reader.new io
42
46
  valid_entries = []
43
47
  reader.pages[2..-1].each do |page|
@@ -3,25 +3,27 @@
3
3
  class ThirteenF
4
4
  class Position
5
5
  attr_reader :name_of_issuer, :title_of_class, :cusip, :value_in_thousands,
6
- :shares_or_principal_amount_type, :shares_or_principal_amount, :put_or_call,
7
- :investment_discretion, :other_managers, :voting_authority, :filing
6
+ :shares_or_principal_amount_type, :shares_or_principal_amount,
7
+ :put_or_call, :investment_discretion, :other_managers, :voting_authority,
8
+ :filing, :time_accepted
8
9
 
9
10
  def self.from_xml_filing(filing)
10
11
  return nil unless filing.table_xml_url
11
12
  from_xml_url(filing.table_xml_url, filing: filing)
12
13
  end
13
14
 
14
- def self.from_xml_url(table_xml_url, filing: nil)
15
+ def self.from_xml_url(table_xml_url, filing: nil, time_accepted: nil)
15
16
  xml_doc = SecRequest.get table_xml_url, response_type: :xml
16
17
  xml_doc.search("//infoTable").map do |info_table|
17
- position = new filing: filing
18
+ position = new filing: filing, time_accepted: time_accepted
18
19
  position.attributes_from_info_table(info_table)
19
20
  position
20
21
  end
21
22
  end
22
23
 
23
- def initialize(filing: nil)
24
+ def initialize(filing: nil, time_accepted: nil)
24
25
  @filing = filing
26
+ @time_accepted = time_accepted
25
27
  end
26
28
 
27
29
  def attributes_from_info_table(info_table)
@@ -30,7 +32,7 @@ class ThirteenF
30
32
  @cusip = info_table.search('cusip').text
31
33
  @value_in_thousands = set_value_to_thousands info_table.search('value').text
32
34
  @shares_or_principal_amount_type = info_table.search('sshPrnamtType').text
33
- @shares_or_principal_amount = to_integer(info_table.search('sshPrnamt').text)
35
+ @shares_or_principal_amount = to_float(info_table.search('sshPrnamt').text)
34
36
 
35
37
  not_found = info_table.search('putCall').count == 0
36
38
  @put_or_call = info_table.search('putCall').text unless not_found
@@ -38,9 +40,9 @@ class ThirteenF
38
40
  @investment_discretion = info_table.search('investmentDiscretion').text
39
41
  @other_managers = info_table.search('otherManager').text
40
42
  @voting_authority = {
41
- sole: to_integer(info_table.search('Sole').text),
42
- shared: to_integer(info_table.search('Shared').text),
43
- none: to_integer(info_table.search('None').text)
43
+ sole: to_float(info_table.search('Sole').text),
44
+ shared: to_float(info_table.search('Shared').text),
45
+ none: to_float(info_table.search('None').text)
44
46
  }
45
47
  end
46
48
 
@@ -54,15 +56,15 @@ class ThirteenF
54
56
  # quarter ending December 31, 2022, and for any other preceding or
55
57
  # succeeding calendar quarter), must use the updated Form 13F.
56
58
  def set_value_to_thousands(text)
57
- before_change = filing.time_accepted < Date.parse('2023-01-03')
59
+ before_change = time_accepted < Date.parse('2023-01-03')
58
60
  if before_change
59
- to_integer(text)
61
+ to_float(text)
60
62
  else
61
- to_integer(text) / 1000
63
+ to_float(text) / 1000
62
64
  end
63
65
  end
64
66
 
65
- def to_integer(text)
67
+ def to_float(text)
66
68
  text.delete(',').to_f
67
69
  end
68
70
  end
@@ -33,6 +33,8 @@ class ThirteenF
33
33
  response = HTTP.use(:auto_inflate).headers(www_headers).get(url)
34
34
  handle_response response, response_type: response_type
35
35
  end
36
+ rescue
37
+ raise "Request failed at this url: #{url} \n With this response #{response.to_s}"
36
38
  end
37
39
 
38
40
  def self.post(url, json)
@@ -1,3 +1,3 @@
1
1
  class ThirteenF
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thirteen_f
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Savannah Fischer