diff --git a/scripts/check_fee_schedule.py b/scripts/check_fee_schedule.py index 0591cef..16db6a2 100644 --- a/scripts/check_fee_schedule.py +++ b/scripts/check_fee_schedule.py @@ -494,12 +494,17 @@ def compare_sec(advisory: SecAdvisory, config: Mapping[str, Any], report: Report def compare_taf_years(label: str, official: Mapping[int, Taf], config: Mapping[str, Any], - years: range, report: Report) -> None: + years: range, report: Report, + *, allow_missing_before_year: int | None = None) -> None: mismatches = [] + checked_years = [] for year in years: if year not in official: + if allow_missing_before_year is not None and year < allow_missing_before_year: + continue mismatches.append(f"{year}: missing in {label}") continue + checked_years.append(year) repo = repo_taf_on(config, date(year, 1, 1)) if repo != official[year]: mismatches.append(f"{year}: {label} {official[year][0]} / {official[year][1]}, " @@ -507,8 +512,9 @@ def compare_taf_years(label: str, official: Mapping[int, Taf], config: Mapping[s if mismatches: report.findings.append(f"FINRA TAF ({label}) differs from the schedule: " + "; ".join(mismatches)) else: + span = f"{checked_years[0]}-{checked_years[-1]}" if checked_years else f"{years.start}-{years.stop - 1}" report.notes.append( - f"FINRA TAF ({label}): covered-equity rate and cap for {years.start}-{years.stop - 1} " + f"FINRA TAF ({label}): covered-equity rate and cap for {span} " "match the schedule.") @@ -562,11 +568,14 @@ def sec(url: str) -> str: else: report.notes.append(f"SEC page for {filing}: no suspension mentioned.") - # FINRA: original schedule table, years up to 2026 (later years were deferred) + # FINRA: original schedule table, years up to 2026 (later years were deferred). + # FINRA's live webpage drops past calendar years once archived; tolerate absent + # prior-year columns while still checking any row that remains published. report.source(FINRA_SCHEDULE_URL) compare_taf_years("fee adjustment schedule SR-FINRA-2024-019", parse_finra_schedule_table(fetch_html(FINRA_SCHEDULE_URL)), - config, range(2024, 2027), report) + config, range(2024, 2027), report, + allow_missing_before_year=date.today().year) # FINRA: new TAF filings that have not been reviewed report.source(FINRA_LISTING_URL) diff --git a/tests/test_check_fee_schedule.py b/tests/test_check_fee_schedule.py index 95f5265..c97140b 100644 --- a/tests/test_check_fee_schedule.py +++ b/tests/test_check_fee_schedule.py @@ -205,6 +205,45 @@ def test_compare_taf_years_reports_each_difference_and_missing_years(): assert "2027" in report.findings[0] and "2028: missing" in report.findings[0] +def test_compare_taf_years_allows_missing_archived_past_years(): + official = {2026: TAF_2026} + report = cfs.Report() + cfs.compare_taf_years("test", official, config(), range(2024, 2027), report, allow_missing_before_year=2026) + assert report.findings == [] + assert "2026-2026" in report.notes[0] + + missing_current = cfs.Report() + cfs.compare_taf_years("test", {}, config(), range(2024, 2027), missing_current, allow_missing_before_year=2026) + assert len(missing_current.findings) == 1 + assert "2026: missing" in missing_current.findings[0] + assert "2024: missing" not in missing_current.findings[0] + + +def test_full_run_tolerates_archived_past_years_removed_from_finra_schedule(monkeypatch): + # Keep 2026..2029 in the table while removing archived 2024 and 2025 columns. + schedule_html = fixture("finra_schedule.html") + for col in ( + "2024", + "2025 (no change)", + "$0.000166 per share (up to $8.30 max per trade)$0.000166 per share (up to $8.30 max per trade)", + "$0.00279 per contract$0.00279 per contract", + "$0.00011 per contract (with $0.014 minimum per round turn transaction)$0.00011 per contract (with $0.014 minimum per round turn transaction)", + "$0.00105 per bond (up to $1.05 max per trade)$0.00105 per bond (up to $1.05 max per trade)", + "$0.00000105 times reported value (up to $1.05 max per trade)$0.00000105 times reported value (up to $1.05 max per trade)", + ): + assert col in schedule_html + schedule_html = schedule_html.replace(col, "", 1) + + class FixedDate(date): + @classmethod + def today(cls) -> date: + return date(2026, 11, 28) + + monkeypatch.setattr(cfs, "date", FixedDate) + report = offline_run(config(), {cfs.FINRA_SCHEDULE_URL: schedule_html}) + assert report.findings == [] + + def test_compare_pause_checks_window_and_previous_rate(): cfg = config() window = cfs.repo_pause(cfg)