edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

get_fund method only gets the first page's NPORT-P filings

Open byqpzs opened this issue 1 year ago • 8 comments

init_ticker = 'CAAPX'
fund = get_fund(init_ticker)
filings = fund.filings.filter(form="NPORT-P")
print(len(filings))

the output is 9, but actually, there are 22 NPORT-P filings

version: edgartools-3.12.1 python-3.12

byqpzs avatar Mar 06 '25 02:03 byqpzs

Yes this is a bug.

By default the filling data coming back is just the first page. In an older version of the code it would loop through all the pages and fetch all the filings. This was changed to have filings only return the first page and get_filings trigger the full load - necessary to get fillings to work with LocalStorage. However, funds were not updated to trigger the full load.

The other issues is that filings and get_filings might be confusing so I will think about maybe changing filings to _filings and just have users use get_filings when I add it to the Funds class.

I will see what I can do this weekend

dgunning avatar Mar 07 '25 17:03 dgunning

This is fixed internally - testing now. Should be available in a couple days

dgunning avatar Mar 09 '25 02:03 dgunning

Fixed in 3.12.2

dgunning avatar Mar 10 '25 12:03 dgunning

@dgunning Thanks for the fix. But it seems like nothing has changed in 3.12.2. I updated edgartools to version 3.12.2, and the output is still 9.

Fixed in 3.12.2

byqpzs avatar Mar 11 '25 03:03 byqpzs

You should see the following with edgartools 3.12.2

Image

See if you can check if the code has changed in your environment

python -c "import inspect; import edgar; print(inspect.getsource(edgar.funds.get_fund_with_filings))"

You should see the while loop that gets more filings

def get_fund_with_filings(contract_or_series_id: str):
    """Uses this url https://www.sec.gov/cgi-bin/browse-edgar?CIK={}
       to get the fund class or series including the filings

    """
   ... previous code
    filing_index = company_info.filings.data
    while True:
        # Get the next page
        next_page = base_url + f"&start={start}&count={count}"
        fund_text = download_text(next_page)
        soup = BeautifulSoup(fund_text, features="html.parser")
        filing_index_on_page = FundCompanyInfo.extract_filings(soup, company_info.name, company_info.cik)
        if len(filing_index_on_page) == 0:
            break
        filing_index = pa.concat_tables([filing_index, filing_index_on_page])
        start += count

I will test on a different machine and see if the functionality has changed

dgunning avatar Mar 11 '25 12:03 dgunning

    f=get_fund("CAAPX")
    filings=f.filings.filter(form="NPORT-P")
    print(f)
    print(filings)
    print(len(filings))

Image

python -c "import inspect; import edgar; print(inspect.getsource(edgar.funds.get_fund_with_filings))"

Image

byqpzs avatar Mar 12 '25 04:03 byqpzs

Can you try to run this notebook

https://github.com/dgunning/edgartools/blob/main/notebooks/Fund-Filings.ipynb

dgunning avatar Mar 13 '25 12:03 dgunning

sorry, it's my local Python environment problem. It's fixed.

byqpzs avatar Mar 14 '25 03:03 byqpzs