Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add the 13f data directly from the FMP #6956

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

joshuaBri
Copy link

Why?:

Expand the 13f data directly from the FMP
What?:

Adds fmp as a provider to, obb.equity.ownership
Impact:

Get Data of 13FHR from fmp provider

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@joshuaBri joshuaBri changed the title Feature/13f [Feature] Add the 13f data directly from the FMP Nov 22, 2024
Copy link
Contributor

@deeleeramone deeleeramone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR. It's off to a nice start, let's bring it home!

There are some FMP-related issues that become ours' without getting out ahead of them.

  • For this function, the symbol input needs to accept both a ticker symbol and a CIK number. There needs to be a translation/check for this.
    • obb.equity.ownership.form_13f(symbol="0001045810", provider="fmp")
    • obb.equity.ownership.form_13f(symbol="NVDA", provider="fmp")
  • Getting the most recent filing shouldn't require a date, and when a date is entered, it needs to find the appropriate one - i.e, a successful request shouldn't hinge on knowing the exact right date.
  • We want to be able to get more than one at a time (from the same CIK, not so much multiple CIKs) so that the changes can be easily observed. The "limit" param can be a convenience method for the user to fetch the most recent N filing.

"asset_class": "titleOfClass",
"filling_date": "fillingDate",
"accepted_date": "acceptedDate",
"ticker_cusip": "tickercusip",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ticker_cusip" -> "symbol"

"ticker_cusip": "tickercusip",
"final_link": "finalLink",
}
filling_date: dateType = Field(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where fields have default=None, they need to be annotated as, Optional[type]

query: FMPForm13FHRQueryParams, data: List[Dict], **kwargs: Any
) -> List[FMPForm13FHRData]:
"""Return the transformed data."""
return [FMPForm13FHRData(**d) for d in data]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FMP is returning an additional field, "cik", which we do not want because it is the filer's CIK and having this value makes things both confusing and redundant. Please pop that value before returning the response.

query,
exclude=["symbol", "limit"],
)
result = await amake_request(url, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we can handle API authorization errors if we pass a specific response_callback helper function to amake_request

from openbb_fmp.utils.helpers import response_callback
result = await amake_request(url, response_callback=response_callback, **kwargs)

Obviously, you wouldn't be likely to know this, but it will ensure that authorization error messages get properly communicated to the user.

if result:
results.extend(result)

await asyncio.gather(*[get_one(symbol) for symbol in symbols])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted already, we are more interested in getting multiple filings from the same symbol, rather than the same date for multiple symbols. If we only allow 1 symbol, but multiple dates, we'll need to handle each date for the given symbol.



@pytest.mark.record_http
def test_fmp_form_13f_fetcher(credentials=test_credentials):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In, openbb_platform/extensions/equity/integration, there are two test files for the integration tests, API and Python. A full set of parameters (can be None if the param is optional) with provider='fmp' needs to be added to the params of the endpoint test. Insert them below the "sec" provider params.

@joshuaBri
Copy link
Author

joshuaBri commented Nov 25, 2024

Thanks a lot for your correction.But I still have some troubles:
I can't see through how provider "sec" fix the problem with ticker-to-cik map,or it can fetch the data directly through ticker.But FMP can't fetch the data directly through ticker. I have to get the cik first.
I can fetch the related data through the url --https://www.sec.gov/files/company_tickers.json
Can I use it in coding ?
image

@deeleeramone
Copy link
Contributor

Thanks a lot for your correction.But I still have some troubles: I can't see through how provider "sec" fix the problem with ticker-to-cik map,or it can fetch the data directly through ticker.But FMP can't fetch the data directly through ticker. I have to get the cik first. I can fetch the related data through the url --https://www.sec.gov/files/company_tickers.json Can I use it in coding?

No, you'll need to use FMP endpoints for FMP data - https://site.financialmodelingprep.com/developer/docs/cik-search-company-search

@joshuaBri
Copy link
Author

joshuaBri commented Nov 26, 2024

Thanks a lot for your correction.But I still have some troubles: I can't see through how provider "sec" fix the problem with ticker-to-cik map,or it can fetch the data directly through ticker.But FMP can't fetch the data directly through ticker. I have to get the cik first. I can fetch the related data through the url --https://www.sec.gov/files/company_tickers.json Can I use it in coding?

No, you'll need to use FMP endpoints for FMP data - https://site.financialmodelingprep.com/developer/docs/cik-search-company-search
Sorry, I don't think you get my point. For example , I want to get the cik of ticker "NVDA". Where can I get the cik for this ticker?
The endpoint you mentioned can't help me to get the cik. If i don't have cik,I can't use the FMP endpoints to fetch 13F data.

@deeleeramone
Copy link
Contributor

Sorry, I don't think you get my point. For example , I want to get the cik of ticker "NVDA". Where can I get the cik for this ticker?

I understand, personally I find their documentation and labeling to be confusing, perhaps this one is better.

https://site.financialmodelingprep.com/developer/docs/institutional-holders-search-api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants