Feature: EOD time management module - di.eodtime#94
Open
alowrydi wants to merge 3 commits into
Open
Conversation
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.
EOD time management module, di.eodtime
Extracts code/common/eodtime.q from TorQ and packages it as a standalone kdb-x module. Manages end-of-day timing for tickerplant processes, resolves the current trading date in a configurable timezone, calculates when the next EOD roll is due in UTC, and provides a UTC offset used to timestamp incoming market data.
Trello ticket - https://trello.com/c/rMbaJnZU/87-kdb-x-eod-module
This PR references
di.tz. The timezone rename PR must merge before this one.Files created
How to test
Unit test example:
Coverage includes: all 9 exported functions across 15 test groups covering all exported functions, GMT/UTC shortcut behaviour, timezones in both winter and summer, offset behaviour, and the init function with various arguments.
Design decisions
1. di.tz as hard dependency - Rather than duplicating timezone conversion logic, di.tz is loaded via tz:use\di.tzininit.q.
2. Setter and getter functions - In TorQ, processes update/overwrite .eodtime.* variables directly in the process code (e.g. stplog.q does .eodtime.d+:1 after each EOD roll). Since direct assigning of variables inside the module is not possible, setter functions (setd, setnextroll, setdailyadj) were introduced so values can be updated. The full TorQ migration mapping is documented in eodtime.md.
3. UTC-equivalent timezone shortcuts - "GMT", "UTC" and "Etc/GMT" are not in the timezone database used by di.tz and cause a notValidTimezone error if passed through. Since "GMT" is TorQ's default timezone, these are short-circuited to return 0D directly. This ensures the module works out of the box with existing TorQ deployments (backwards compatibility). Note: "Etc/UTC" is valid in di.tz and passes through normally.
4. Graceful DST handling - Non-GMT timezones are handled gracefully. adjtime and getdailyadjustment both call di.tz at runtime rather than caching a static offset, so DST transitions are picked up automatically. This is verified in the test suite with Europe/London in both winter (UTC+0) and summer (UTC+1).
Checklist
Documentation
See eodtime.md for full reference including config table, exported function documentation, usage example, and TorQ migration pattern table.