Skip to content

Feature: EOD time management module - di.eodtime#94

Open
alowrydi wants to merge 3 commits into
mainfrom
feature-eodtime
Open

Feature: EOD time management module - di.eodtime#94
alowrydi wants to merge 3 commits into
mainfrom
feature-eodtime

Conversation

@alowrydi
Copy link
Copy Markdown
Contributor

@alowrydi alowrydi commented Jun 3, 2026

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

⚠️ Dependency: merge after Renaming of timezone to tz
This PR references di.tz . The timezone rename PR must merge before this one.

Files created

File Description
di/eodtime/init.q Loads di.tz dependency, loads eodtime.q, defines export of 9 functions
di/eodtime/eodtime.q Full implementation - module state, internal helpers, public API, init
di/eodtime/eodtime.md Full module documentation - see below
di/eodtime/test.csv 37 k4unit tests across 15 test groups

How to test

k4unit:use`di.k4unit

k4unit.moduletest`di.eodtime

Unit test example:

q)k4unit.moduletest`di.eodtime;
2026.06.03T10:26:53.070 start
2026.06.03T10:26:53.070 :/home/alowry/bin/local-kdbx-modules/di/eodtime/test.csv 37 test(s)
2026.06.03T10:26:53.070 end
Test results:
action ms bytes lang code                                                                                               repeat file                                                     msx bytesx ok okms okbytes valid timestamp
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
true   0  0     q    -14h=type eodtime.getd[]                                                                           1      :/home/alowry/bin/local-kdbx-modules/di/eodtime/test.csv 0   0      1  1    1       1     2026.06.03T10:26:53.070
true   0  0     q    -12h=type eodtime.getnextroll[]                                                                    1      :/home/alowry/bin/local-kdbx-modules/di/eodtime/test.csv 0   0      1  1    1       1     2026.06.03T10:26:53.070
true   0  0     q    eodtime.getnextroll[]>.z.p                                                                         1      :/home/alowry/bin/local-kdbx-modules/di/eodtime/test.csv 0   0      1  1    1       1     2026.06.03T10:26:53.070
true   0  0     q    -16h=type eodtime.getdailyadj[]                                                                    1      :/home/alowry/bin/local-kdbx-modules/di/eodtime/test.csv 0   0      1  1    1       1     2026.06.03T10:26:53.070
true   0  0     q    0D=eodtime.getdailyadj[]                                                                           1      :/home/alowry/bin/local-kdbx-modules/di/eodtime/test.csv 0   0      1  1    1       1     2026.06.03T10:26:53.070
true   0  0     q    -16h=type eodtime.getdailyadjustment[]                                                             1      :/home/alowry/bin/local-kdbx-modules/di/eodtime/test.csv 0   0      1  1    1       1     2026.06.03T10:26:53.070
. .
q)exec sum ok from k4unit.getresults[] // 37/37 pass
37i

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

  • • 37/37 k4unit tests passing
  • • Follows consistency.md and style.md
  • • eodtime.md documents all exported functions, config, usage example and TorQ migration table
  • Renaming of timezone to tz merged

Documentation
See eodtime.md for full reference including config table, exported function documentation, usage example, and TorQ migration pattern table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant