Skip to content

Freeze schedules of test versions of CMES and XHKG cals to match test resources - #591

Merged
maread99 merged 1 commit into
masterfrom
claude/epic-allen-yqdys8
Nov 27, 2026
Merged

maread99 merged 1 commit into
masterfrom
claude/epic-allen-yqdys8

Conversation

@maread99

@maread99 maread99 commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

🤖 Crafted with Claude Code (agent autonomy 3/5)

Summary

Pin calendar schedules used by test suite to as they were defined as at exchange-calendars 4.13.2:

  • 4.13.3 corrects the CMES close and adds two XHKG closures. The stored test resources predate 4.13.3, so the tests now evaluate them against CMESAsAt4132 and XHKGAsAt4132 (tests/utils.py), which reproduce these calendars as at 4.13.2.
  • The dependencies-management skill now directs future calendar corrections of this kind to the classes notes above.
  • Fixes PTIntraday.sessions raising IndexError rather than returning NaT. Revises an existing test to fail without this fix.

Closes #589.


  • I've reviewed/revised the PR title (if unticked, treat it as an agent's unchecked title).
  • I've reviewed/revised the summary above and it covers what a reviewer needs to know (if unticked, treat it as an agent's unchecked summary).

Agent autonomy

The contributor proposed freezing the CMES calendar within the test suite and registering the frozen XHKG calendar under a new name, chose the names, and drove several rounds of revision, including supplying revisions to the docstrings of the calendar classes; the agent investigated the failures, proposed freezing XHKG, moving the classes to tests/utils.py and the remaining changes, and wrote the implementation.

Contributor review

I have reviewed the (tick all that apply):

  • full diff across the code base
  • full diff across the test suite
  • full diff across dev files
  • commit messages
  • agent's detail below
Claude Opus 5.5 Extra

Summary

exchange_calendars 4.13.3 corrects two calendars that the stored test resources were created with:

  • CMES: the close moves from 17:00 to 16:00 America/Chicago (CME's daily halt). CMES sessions no longer abut, so TestDownsampleIntraday::test_excess_row_handling_and_lengths fails. So do the tests that compare the prices of ES=F with the CMES calendar (TestIndicesTradingStatus::test_intraday_pt, TestIndicesTradingStatus::test_composite_intraday_pt and TestDownsampleIntraday::test_reindex_equivalence).
  • XHKG: 2023-09-01 and 2023-09-08 become closures. test_to_csv fails because the 9988.HK csv resource has rows for both dates.

The stored resources cannot readily be re-created (Yahoo serves intraday data only for recent periods), so this PR freezes the calendars rather than the data.

Changes

  • tests/utils.py: adds CMESAsAt4132, which restores the 17:00 close, and XHKGAsAt4132, which excludes the two closures. Each class's docstring states which changes to exchange_calendars the class should revert and lists each change that it reverts.
  • tests/test_pt.py: the cmes fixture yields CMESAsAt4132. test_excess_row_handling_and_lengths keeps its original premise that composite sessions abut. Its docstring now defines excess rows and its comments are revised.
  • tests/test_base_prices.py: the calendars fixture of the test_to_csv tests registers XHKGAsAt4132 with exchange_calendars as 'XHKG_4132' (deregistered on teardown) and maps 9988.HK to that name. PricesCsv therefore still creates every calendar from a name.
  • src/market_prices/pt.py: PTIntraday.sessions returns NaT, rather than raising IndexError, if a composite calendar has no session to assign to an indice. The corrected CMES calendar exposed the bug. With CMES frozen, test_sessions now also evaluates a composite calendar of XNYS and XLON (which has minutes outside every session) so that the fix remains covered.
  • .agents/skills/dependencies-management/SKILL.md: step 6 directs that a test failure caused by such a calendar correction be fixed in these classes rather than by editing the resources.
  • Fixes typos in the PricesCsvIgnoredUnalignedIndicesWarning message (and the test_csv expectations), in the PTIntraday.downsample docstring and in test comments. Corrects the symbols in the composite_intraday_pt docstring.

Of #588's changes, this PR includes the sessions fix and the warning-message typo fix. It does not include #588's dependency and version-pin bumps (left to the next dependency update), its removal of two rows from the 9988.HK csv (which works only under 4.13.3) or its exclusion of ES=F from three tests (unnecessary with CMES frozen).

Verification

  • test_pt.py, test_helpers.py, test_csv.py and test_base_prices.py::test_to_csv pass under 4.13.2 (this branch's lock) and under 4.13.3 (with Update Dependencies Nov 25 (auto) #588's lock).
  • With the sessions fix removed, test_sessions fails under both versions.
  • The full suite was last run under 4.13.2 before the classes moved to tests/utils.py (the affected modules were re-run after the move): 1437 passed, 4 failed and 40 errored. Every failure and error is in a network test: test_calendar_utils.py fetches from a host that the session's network blocks, and three test_yahoo.py tests depend on live Yahoo responses. These tests failed in the same way on the commit before the changes. CI is the arbiter of the network tests.
  • mypy reports no new errors in pt.py.

Noticed in passing (not changed)

  • CompositeCalendar.minute_to_sessions returns a session for a minute that falls in a gap within a composite session (it evaluates the span from open to close), whereas its docstring and the class Notes describe such a minute as non-trading.
  • The comment "session overlap, assign to calendar session" in PTIntraday._downsample_open also covers minutes that fall in no composite session.
  • No test uses the intraday_cc_overlapping_pt fixture.
  • The tests take XNYS and XLON directly from exchange_calendars. A future correction to either over the periods of the stored resources would need an *AsAt class of its own.

🤖 Generated with Claude Code


Generated by Claude Code

exchange_calendars 4.13.3 moves the CMES close from 17:00 to 16:00
America/Chicago and adds two 2023 closures to XHKG. The stored price
tables and the csv files of the 'to_csv' resources directory were
created before 4.13.3 and are consistent with the earlier calendars.
With 4.13.3, `test_excess_row_handling_and_lengths` and `test_to_csv`
fail, as do tests that compare the prices of ES=F with the CMES
calendar.

tests/utils.py now defines calendars as at exchange_calendars 4.13.2,
which the tests evaluate the stored resources against so that the tests
pass with both 4.13.2 and 4.13.3:
- `CMESAsAt4132` restores the 17:00 close. The `cmes` fixture of
  tests/test_pt.py yields this calendar.
- `XHKGAsAt4132` excludes the two closures. The `calendars` fixture of
  the `test_to_csv` tests registers this class under the name
  'XHKG_4132' and maps 9988.HK to that name.

Each class's docstring states which changes to exchange_calendars the
class should revert and lists each change that it reverts. The
dependencies-management skill directs that a test failure caused by an
exchange_calendars correction to a calendar that stored test resources
were created with be fixed by reverting the correction in such a class,
rather than by editing the resources.

Fixes `PTIntraday.sessions`, which raised IndexError rather than
returning NaT if a composite calendar has no session to assign to an
indice (for example if `direction` is None and the indice falls outside
every session). `test_sessions` now also evaluates a composite calendar
that has minutes outside every session.

Also:
- documents excess rows in `test_excess_row_handling_and_lengths` and
  revises the test's comments.
- corrects the symbols in the `composite_intraday_pt` docstring.
- fixes typos in the `PricesCsvIgnoredUnalignedIndicesWarning` message,
  in the `PTIntraday.downsample` docstring and in test comments.

Closes #589.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maread99 maread99 added bug Something isn't working tests All things tests agents Coding agent context labels Nov 27, 2026 — with Claude
@maread99 maread99 added Fix Bug fix and removed bug Something isn't working labels Nov 27, 2026
@maread99 maread99 changed the title Freeze CMES and XHKG calendars of stored test resources Freeze schedules of test versions of CMES and XHKG cals to match test resources Nov 27, 2026
@maread99
maread99 merged commit 7ef9fe5 into master Nov 27, 2026
7 checks passed
@maread99
maread99 deleted the claude/epic-allen-yqdys8 branch November 27, 2026 11:11
@maread99 maread99 mentioned this pull request Nov 27, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Coding agent context Fix Bug fix tests All things tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_excess_row_handling_and_lengths needs redesigning: CMES/XNYS no longer abut with zero gap

2 participants