dgunning / edgartools

Python library for working with SEC Edgar
MIT License
345 stars 74 forks source link

Bug in FundReport pulling ISIN #15

Closed Seaworthiness closed 8 months ago

Seaworthiness commented 8 months ago

import pandas as pd from edgar import *

set_identity("Sample sample@domain.com") to_drop = ['ticker', 'maturity_date', 'annualized_rate','desc_other_units', 'is_default', 'cash_collateral','non_cash_collateral', 'restricted'] fund = Company("MDY")
latest_holdings = Company("MDY").get_filings(form="NPORT-P")[0] fund_report = latest_holdings.obj().investment_data() invest_table = fund_report.drop(to_drop, axis=1)

print(invest_table)

all the ISINs are the same:

                        name                         title  \

0 Hubbell Inc Hubbell Inc
1 Builders FirstSource Inc Builders FirstSource Inc
2 Reliance Steel & Aluminum Co Reliance Steel & Aluminum Co
3 Graco Inc Graco Inc
4 Jabil Inc Jabil Inc

                  lei      cusip          isin           balance units  \

0 54930088VDQ6840Y6597 443510607 US3719011096 453329.00000000 NS
1 549300W0SKP6L3H7DP63 12008R107 US3719011096 1084228.00000000 NS
2 549300E287ZOFT3C5Z56 759509102 US3719011096 497354.00000000 NS
3 4T5VJ4S81BRT6Q7GGT78 384109104 US3719011096 1424046.00000000 NS
4 5493000CGCQY2OQU7669 466313103 US3719011096 1122419.00000000 NS

dgunning commented 8 months ago

Thanks for raising this. Taking a look.

dgunning commented 8 months ago

Released version 2.4.7 with a fix for this

dgunning commented 8 months ago

Fixed

Seaworthiness commented 8 months ago

thank you. BTW, seems like fund = Company("ticker") wouldn't work for a mutual fund ticker. It needs the CIK not ticker. Ideally, if you would want it to return the CIK for an equity ticker, and then a class_id for a mutual fund ticker. The CIK for a mutual fund is used across many funds. For example, Vanguard uses the same CIK for all their Admiral Funds, whereas the class_id is for one specific mutual fund.

dgunning commented 8 months ago

Thanks.

I added a few ways to get fund information.

You can now do Fund(<ticker>) Fund(<class_id>) or Fund(<series>) to find a Fund, ClassContract or Series So this will get you the Fidelity 500 Index Fund

Fund("FXAIX")

There is also a generic find function that you can use to search by

Seaworthiness commented 8 months ago

Thanks, that would be a handy mapping function to have. I tested it out and got the following results. Looks like I map 'FCNTX' to a CIK and then call the FundReport object, then the series, ticker and class id is different. Also, the Class column for get_fund_company shows the name of the fund instead of the class_id.

init_ticker = 'FCNTX'
fund = Fund(ticker)
init_cik = fund.company_cik
init_series = fund.series
init_ticker = fund.ticker
print(f"CIK :", init_cik)
print(f"Series :", init_series)
print(f"Ticker :", init_ticker)
print(fund.get_fund_company)

latest_holdings = Company(init_cik).get_filings(form="NPORT-P").latest()
print(latest_holdings.obj().series_and_contracts)
print(latest_holdings.obj().general_info)

CIK : 0000024238 Series : S000006037 Ticker : FCNTX <bound method FundObject.get_fund_company of ╭─────────────────────┬────────────┬────────┬─────────────────────╮ │ Fund │ Series │ Ticker │ Class │ ├─────────────────────┼────────────┼────────┼─────────────────────┤ │ Fidelity Contrafund │ S000006037 │ FCNTX │ Fidelity Contrafund │ ╰─────────────────────┴────────────┴────────┴─────────────────────╯

Fund Series and Contracts

Fund Ticker SeriesID ContractID Class CIK
───────────────────────────────────────────────────────────────────────────────────────────────────────────────── Fidelity Series Opportunistic FVWSX S000039220 C000120656 Fidelity Series Opportunistic 0000024238
Insights Fund Insights Fund

GeneralInfo(name='Fidelity Contrafund', cik='0000024238', file_number='811-01400', lei='S5Y3O6VQ0TG5C3WLJP73', street1='245 Summer Street', street2=None, city='Boston', state='US-MA', country='US', zip_or_postal_code='02210', phone='1-800-FIDELITY', series_name='Fidelity Series Opportunistic Insights Fund', series_lei='5493004275RP9SSN9N07', series_id='S000039220', reg_period_end='2023-12-31', reg_period_date='2023-06-30', is_final_filing=False)