Repository navigation
Freeze schedules of test versions of CMES and XHKG cals to match test resources - #591
Merged
Merged
Conversation
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>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Crafted with Claude Code (agent autonomy 3/5)
Summary
Pin calendar schedules used by test suite to as they were defined as at
exchange-calendars4.13.2:CMESAsAt4132andXHKGAsAt4132(tests/utils.py), which reproduce these calendars as at 4.13.2.PTIntraday.sessionsraisingIndexErrorrather than returningNaT. Revises an existing test to fail without this fix.Closes #589.
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.pyand the remaining changes, and wrote the implementation.Contributor review
I have reviewed the (tick all that apply):
Claude Opus 5.5 Extra
Summary
exchange_calendars4.13.3 corrects two calendars that the stored test resources were created with:TestDownsampleIntraday::test_excess_row_handling_and_lengthsfails. So do the tests that compare the prices of ES=F with the CMES calendar (TestIndicesTradingStatus::test_intraday_pt,TestIndicesTradingStatus::test_composite_intraday_ptandTestDownsampleIntraday::test_reindex_equivalence).test_to_csvfails 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: addsCMESAsAt4132, which restores the 17:00 close, andXHKGAsAt4132, which excludes the two closures. Each class's docstring states which changes toexchange_calendarsthe class should revert and lists each change that it reverts.tests/test_pt.py: thecmesfixture yieldsCMESAsAt4132.test_excess_row_handling_and_lengthskeeps its original premise that composite sessions abut. Its docstring now defines excess rows and its comments are revised.tests/test_base_prices.py: thecalendarsfixture of thetest_to_csvtests registersXHKGAsAt4132withexchange_calendarsas 'XHKG_4132' (deregistered on teardown) and maps 9988.HK to that name.PricesCsvtherefore still creates every calendar from a name.src/market_prices/pt.py:PTIntraday.sessionsreturnsNaT, rather than raisingIndexError, if a composite calendar has no session to assign to an indice. The corrected CMES calendar exposed the bug. With CMES frozen,test_sessionsnow 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.PricesCsvIgnoredUnalignedIndicesWarningmessage (and thetest_csvexpectations), in thePTIntraday.downsampledocstring and in test comments. Corrects the symbols in thecomposite_intraday_ptdocstring.Of #588's changes, this PR includes the
sessionsfix 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.pyandtest_base_prices.py::test_to_csvpass under 4.13.2 (this branch's lock) and under 4.13.3 (with Update Dependencies Nov 25 (auto) #588's lock).sessionsfix removed,test_sessionsfails under both versions.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.pyfetches from a host that the session's network blocks, and threetest_yahoo.pytests 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.pt.py.Noticed in passing (not changed)
CompositeCalendar.minute_to_sessionsreturns 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.PTIntraday._downsample_openalso covers minutes that fall in no composite session.intraday_cc_overlapping_ptfixture.exchange_calendars. A future correction to either over the periods of the stored resources would need an*AsAtclass of its own.🤖 Generated with Claude Code
Generated by Claude Code