This is a guest post by Mark Street. If you like it be sure to check out his other posts, or find him on LinkedIn. If you are interested in being a guest blogger on enlist[q], please contact me.
As we previously learnt, q/kdb+ has a callback function .z.ts
which fires an event every x
milliseconds, where x
is the precision applied to the time via the \t
command.
q)\t 100 / set .z.ts to fire every 100 milliseconds
This works just fine if we want to fire a single function at the same period (e.g. when running the TickerPlant in batch mode), but leaves us a little stuck if we want to execute different functions at different intervals.
An approach to solving this, is to create and maintain a list of functions we want to call, along with the interval that they should be triggered, and, when the .z.ts
callback is fired, trigger the relevant ones. We will refer to this combination of a function and interval as a ‘job’.