fix(federal_reserve): BHCPR defaults to the newest published quarter (#7854)

The NIC lists a quarter before its report is published; its CSV is an error page. Periods whose pdf_available is false are left out of the filed periods.

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: dlee-bq <dlee@brightquery.com>
This commit is contained in:
Art Cashin
2026-11-29 00:07:45 +00:00
committed by GitHub
parent dbf42dc22e
commit 34bab40b81
2 changed files with 18 additions and 0 deletions

View File

@@ -74,6 +74,8 @@ def _filed_periods(rssd: str) -> list[str]:
return [
_quarter_end(int(period["year"]), int(period["quarter"]))
for period in reports.get("BHCPR", {}).get("periods", [])
# NIC lists a quarter before its report is published; its CSV is an error page.
if period.get("pdf_available", True)
]

View File

@@ -220,6 +220,22 @@ class TestFiledPeriods:
)
assert _filed_periods("1039502") == ["20260331", "20251231"]
def test_listed_quarter_with_no_report_yet_is_left_out(self, monkeypatch):
"""A quarter the NIC lists before its report is published is skipped."""
reports = {
"BHCPR": {
"periods": [
{"year": 2026, "quarter": 3, "pdf_available": False},
{"year": 2026, "quarter": 2, "pdf_available": True},
]
}
}
monkeypatch.setattr(
"openbb_federal_reserve.utils.ffiec.fetch_institution_financial_reports",
lambda rssd: reports,
)
assert _filed_periods("1039502") == ["20260630"]
def test_blank_rssd_returns_empty(self):
"""A blank RSSD yields no filed periods without a fetch."""
assert _filed_periods("") == []