You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.5 KiB
Python
70 lines
2.5 KiB
Python
"""Filing-related Oracle service methods."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from libs.oracle_client.client import OracleClient
|
|
from libs.oracle_client.models import (
|
|
ExhibitDocument,
|
|
ExhibitResponse,
|
|
FilingDocumentsResponse,
|
|
FilingEntry,
|
|
FilingSearchResponse,
|
|
)
|
|
|
|
|
|
class FilingsService:
|
|
def __init__(self, client: OracleClient) -> None:
|
|
self._client = client
|
|
|
|
async def search_filings(
|
|
self,
|
|
ticker: str,
|
|
form_type: str | None = None,
|
|
start_date: str | None = None,
|
|
end_date: str | None = None,
|
|
) -> FilingSearchResponse:
|
|
params: dict[str, str] = {}
|
|
if form_type:
|
|
params["form_type"] = form_type
|
|
if start_date:
|
|
params["start_date"] = start_date
|
|
if end_date:
|
|
params["end_date"] = end_date
|
|
data = await self._client.get(f"/api/v1/filings/search/{ticker}", params=params)
|
|
# Real Oracle: {"ticker": ..., "filings": [{accession_number, form_type, ...}], "total_count": ...}
|
|
filings = [
|
|
FilingEntry(
|
|
accession_no=f["accession_number"],
|
|
form_type=f["form_type"],
|
|
filing_date=f["filing_date"],
|
|
primary_document=f.get("primary_document"),
|
|
description=f.get("filing_description"),
|
|
)
|
|
for f in data.get("filings", [])
|
|
]
|
|
return FilingSearchResponse(
|
|
ticker=data.get("ticker", ticker),
|
|
filings=filings,
|
|
total=data.get("total_count", len(filings)),
|
|
)
|
|
|
|
async def get_documents(self, accession_no: str) -> FilingDocumentsResponse:
|
|
data = await self._client.get(f"/api/v1/filings/documents/{accession_no}")
|
|
exhibits = [ExhibitDocument.model_validate(e) for e in data.get("exhibits", [])]
|
|
return FilingDocumentsResponse(
|
|
accession_no=data.get("accession_number", accession_no),
|
|
exhibits=exhibits,
|
|
)
|
|
|
|
async def get_exhibit(
|
|
self, accession_no: str, exhibit_type: str = "EX-99.1"
|
|
) -> ExhibitResponse:
|
|
params = {"exhibit_type": exhibit_type}
|
|
data = await self._client.get(f"/api/v1/filings/exhibit/{accession_no}", params=params)
|
|
# Real Oracle: {"accession_number": ..., "exhibit_type": ..., "content": ...}
|
|
return ExhibitResponse(
|
|
accession_no=data.get("accession_number", accession_no),
|
|
exhibit_type=data.get("exhibit_type", exhibit_type),
|
|
content=data.get("content", ""),
|
|
)
|