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 Endpoint For The Latest Financial Reports Filed With The SEC #6936

Merged
merged 4 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Latest Financial Reports Standard Model."""

from datetime import date as dateType
from typing import Optional

from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
from openbb_core.provider.utils.descriptions import DATA_DESCRIPTIONS
from pydantic import Field


class LatestFinancialReportsQueryParams(QueryParams):
"""Latest Financial Reports Query."""


class LatestFinancialReportsData(Data):
"""Latest Financial Reports Data."""

filing_date: dateType = Field(description="The date of the filing.")
period_ending: Optional[dateType] = Field(
default=None, description="Report for the period ending."
)
symbol: Optional[str] = Field(
default=None, description=DATA_DESCRIPTIONS.get("symbol")
)
name: Optional[str] = Field(default=None, description="Name of the company.")
cik: Optional[str] = Field(default=None, description=DATA_DESCRIPTIONS.get("cik"))
sic: Optional[str] = Field(
default=None, description="Standard Industrial Classification code."
)
report_type: Optional[str] = Field(default=None, description="Type of filing.")
description: Optional[str] = Field(
default=None, description="Description of the report."
)
url: str = Field(description="URL to the filing page.")
24 changes: 24 additions & 0 deletions openbb_platform/extensions/equity/integration/test_equity_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,3 +2104,27 @@ def test_equity_historical_market_cap(params, headers):
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@parametrize(
"params",
[
(
{
"date": None,
"report_type": None,
"provider": "sec",
}
),
],
)
@pytest.mark.integration
def test_equity_discovery_latest_financial_reports(params, headers):
"""Test the equity discovery latest financial reports endpoint."""
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/equity/discovery/latest_financial_reports?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -1966,3 +1966,26 @@ def test_equity_historical_market_cap(params, obb):
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0


@parametrize(
"params",
[
(
{
"date": None,
"report_type": None,
"provider": "sec",
}
),
],
)
@pytest.mark.integration
def test_equity_discovery_latest_financial_reports(params, obb):
"""Test the equity discovery latest financial reports endpoint."""
params = {p: v for p, v in params.items() if v}

result = obb.equity.discovery.latest_financial_reports(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,20 @@ async def filings(
and audited financial statements.
"""
return await OBBject.from_query(Query(**locals()))


@router.command(
model="LatestFinancialReports",
examples=[
APIEx(parameters={"provider": "sec"}),
APIEx(parameters={"provider": "sec", "date": "2024-09-30"}),
],
)
async def latest_financial_reports(
cc: CommandContext,
provider_choices: ProviderChoices,
standard_params: StandardParams,
extra_params: ExtraParams,
) -> OBBject:
"""Get the newest quarterly, annual, and current reports for all companies."""
return await OBBject.from_query(Query(**locals()))
190 changes: 190 additions & 0 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -15387,6 +15387,196 @@
},
"model": "DiscoveryFilings"
},
"/equity/discovery/latest_financial_reports": {
"deprecated": {
"flag": null,
"message": null
},
"description": "Get the newest quarterly, annual, and current reports for all companies.",
"examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.equity.discovery.latest_financial_reports(provider='sec')\nobb.equity.discovery.latest_financial_reports(provider='sec', date=2024-09-30)\n```\n\n",
"parameters": {
"standard": [],
"sec": [
{
"name": "date",
"type": "Union[date, str]",
"description": "A specific date to get data for. Defaults to today.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "report_type",
"type": "Union[str, List[str]]",
"description": "Return only a specific form type. Default is all quarterly, annual, and current reports. Choices: 1-K, 1-SA, 1-U, 10-D, 10-K, 10-KT, 10-Q, 10-QT, 20-F, 40-F, 6-K, 8-K. Multiple items allowed for provider(s): sec.",
"default": null,
"optional": true,
"choices": [
"1-K",
"1-SA",
"1-U",
"10-D",
"10-K",
"10-KT",
"10-Q",
"10-QT",
"20-F",
"40-F",
"6-K",
"8-K"
]
}
]
},
"returns": {
"OBBject": [
{
"name": "results",
"type": "List[LatestFinancialReports]",
"description": "Serializable results."
},
{
"name": "provider",
"type": "Optional[Literal['sec']]",
"description": "Provider name."
},
{
"name": "warnings",
"type": "Optional[List[Warning_]]",
"description": "List of warnings."
},
{
"name": "chart",
"type": "Optional[Chart]",
"description": "Chart object."
},
{
"name": "extra",
"type": "Dict[str, Any]",
"description": "Extra info."
}
]
},
"data": {
"standard": [
{
"name": "filing_date",
"type": "date",
"description": "The date of the filing.",
"default": "",
"optional": false,
"choices": null
},
{
"name": "period_ending",
"type": "date",
"description": "Report for the period ending.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "symbol",
"type": "str",
"description": "Symbol representing the entity requested in the data.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "name",
"type": "str",
"description": "Name of the company.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "cik",
"type": "str",
"description": "Central Index Key (CIK) for the requested entity.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "sic",
"type": "str",
"description": "Standard Industrial Classification code.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "report_type",
"type": "str",
"description": "Type of filing.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "description",
"type": "str",
"description": "Description of the report.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "url",
"type": "str",
"description": "URL to the filing page.",
"default": "",
"optional": false,
"choices": null
}
],
"sec": [
{
"name": "items",
"type": "str",
"description": "Item codes associated with the filing.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "index_headers",
"type": "str",
"description": "URL to the index headers file.",
"default": "",
"optional": false,
"choices": null
},
{
"name": "complete_submission",
"type": "str",
"description": "URL to the complete submission text file.",
"default": "",
"optional": false,
"choices": null
},
{
"name": "metadata",
"type": "str",
"description": "URL to the MetaLinks.json file, if available.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "financial_report",
"type": "str",
"description": "URL to the Financial_Report.xlsx file, if available.",
"default": null,
"optional": true,
"choices": null
}
]
},
"model": "LatestFinancialReports"
},
"/equity/fundamental/multiples": {
"deprecated": {
"flag": null,
Expand Down
Loading
Loading