Skip to main content
qi.q is a package manager for q/kdb+. It can be fetched with: Linux / Mac:
curl -LO https://alphakdb.com/qi.q
Windows:
Invoke-WebRequest -Uri https://alphakdb.com/qi.q -OutFile qi.q
or by copying from alphakdb.com/qi.q.

Loading qi packages

To load a package, use .qi.import:
/ Example hello.q

\l qi.q
.qi.import`log
.qi.import`cron

hello:{.log.info"Hello, world";}

.cron.add[`hello;.z.p;00:00:01]
.cron.start[]
You can also specify the name of a package at the command line:
q qi.q cron   
A full list of packages may be found here.

Feed handlers

The first time you try to run a feed handler on any given machine, it will likely complain
q qi.q binance
due to missing environment variables and/or dependencies. If it fails, qi will create a profile file at ~/.qi/qi.profile and suggest an alias qi, which will allow the feed handler to run smoothly the next time around. This extra step should only be required once per machine. With a feed running, the function tcounts[] shows the count of each table. If you run into issues with Github rate limiting, see here.

Other feeds

Some feeds require an account (free) and an API key. The following examples will use the qi alias instead of q qi.q.
qi kraken       / no key required
qi massive      / formerly polygon.io, key required
qi alpaca       / key and secret required
For information on how to configure keys, see here.

Using stacks

q processes usually work together as a stack. The tickerplant (tp) is a router that takes data from feeds, and manages subscriptions. To start a tp as part of a stack, run:
qi tp1
The 1 (or any suffix) tells qi that this is a process that lives in a stack. Because no stack has been created, qi will create an example stack dev1, and will place a JSON configuration file in a stacks folder in the current working directory. Other useful commands:
qi rdb1              / start a real time database in the foreground
qi up wdb1           / start a write database in the background
qi up dev1           / start the whole dev1 stack in the background
qi down kraken1      / bring the kraken feed down
qi status dev1       / show the status of dev1's processes
When a feed handler is started in process mode (e.g. binance1), it publishes updates to its assigned tickerplant instead of accumulating data locally.

Hub

The hub process provides a view of all other processes:
qi hub
The hub contains a procs table that lists the various processes. From within the hub, you can control processes and stacks:
q)up `tp1
q)down `rdb1
q)up `dev1      / bring up the whole stack
q)down `dev1
Other useful hub functions:
q)readstack`dev1
q)clonestack[`dev1;`dev3]
q)renamestack[`dev3;`dev4]
q)deletestack`dev4

License

qi.q and its packages are free to use, and distributed under the MIT license.

Questions & Feedback