Skip to content

Commit

Permalink
Bug fix to allow for filers who have no amendment filings closing issue
Browse files Browse the repository at this point in the history
#9. Updated pytest to include a declared user (now required by SEC).
  • Loading branch information
git-shogg committed Jun 22, 2024
1 parent b28521c commit 658210c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions finsec/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pdb
import os
import time
from io import StringIO

_BASE_URL_ = 'https://www.sec.gov'
_13F_SEARCH_URL_ = 'https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK={}&type=13F-HR&count=100'
Expand Down Expand Up @@ -39,7 +40,7 @@ def _get_last_100_13f_filings_url(self):
webpage = requests.get(_13F_SEARCH_URL_.format(self.cik),headers=_REQ_HEADERS_)
soup = bs(webpage.text,"html.parser")
results_table = soup.find(lambda table: table.has_attr('summary') and table['summary']=="Results")
results_table_df = pd.read_html(results_table.prettify())[0]
results_table_df = pd.read_html(StringIO(str(results_table)))[0]

url_endings = []
url_link_col = results_table_df.columns.get_loc("Format")
Expand Down Expand Up @@ -246,7 +247,7 @@ def get_latest_13f_filing(self, simplified:bool = True, amend_filing:bool = True
latest_13f_cover_page, latest_holdings_table, latest_simplified_holdings_table = self._parse_13f_url(url,filing_date)

qtr_year_str = self._recent_qtr_year(self._13f_filings['Filing Date'][0])
if amend_filing:
if amend_filing and len(self._13f_amendment_filings) > 0:
latest_13f_cover_page, latest_holdings_table, latest_simplified_holdings_table = self._apply_amendments(qtr_year_str, latest_13f_cover_page, latest_holdings_table, latest_simplified_holdings_table)

self.filings.update({
Expand Down Expand Up @@ -326,7 +327,7 @@ def get_13f_filing(self, cal_qtr_year:str, amend_filing:bool=True):
cover_page, holdings_table, simplified_holdings_table = self._parse_13f_url(filing_url, filing_url_date)

qtr_year_str = self._recent_qtr_year(filing_url_date)
if amend_filing:
if amend_filing and len(self._13f_amendment_filings)>0:
cover_page, holdings_table, simplified_holdings_table = self._apply_amendments(qtr_year_str, cover_page, holdings_table, simplified_holdings_table)

self.filings.update({
Expand Down
2 changes: 1 addition & 1 deletion finsec/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.0.11"
version = "0.0.12"
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ beautifulsoup4==4.11.1
pandas==1.3.5
requests==2.27.1
lxml==4.8.0
openpyxl==3.0.9
openpyxl==3.0.9
html5lib
2 changes: 1 addition & 1 deletion tests/test_13f.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Test:
def setup_class(self):
self.cik = "0001067983"
self.filing = finsec.Filing(self.cik)
self.filing = finsec.Filing(self.cik, declared_user="finsec package [email protected]")

def test_cik(self):
assert self.filing.cik == self.cik
Expand Down

0 comments on commit 658210c

Please sign in to comment.