Skip to content

OneTick Cloud KDB-X Module Quickstart

This guide shows how to install the OneTick Cloud KDB-X module and retrieve OneTick sample market data as a q table.

Before you begin

Ensure you have:

  • A working KDB-X installation and valid license.
  • The kurl module included with KDB-X.
  • Network access to cloud-auth.parent.onetick.com and rest.cloud.onetick.com, or to the endpoints supplied for your OneTick environment.
  • The OneTick Cloud KDB-X module archive for your platform.

New to KDB-X or OneTick?

If you are new to q and KDB-X, start with A brief introduction to q and KDB-X. If you are new to OneTick SQL, review the OneTick SQL querying examples.

In interactive examples, q) is the q prompt. Enter only the command that follows it.

The release archives use the following platform names:

Archive prefix Platform
l64 Linux x86-64
l64arm Linux ARM64
m64 macOS x86-64 or ARM64

Install the module

Download the appropriate archive from the OneTick Cloud KDB-X module directory in the KX downloads portal. For example, download the latest Linux x86-64 archive with:

curl -L -O https://portal.dl.kx.com/assets/raw/kdb-x/modules/onetickcloud/~latest~/l64-onetickcloud.zip

The following commands use the default KDB-X installation directory, $HOME/.kx. If you installed KDB-X elsewhere, replace $HOME/.kx with your installation directory.

Extract the archive into the KDB-X module directory:

unzip -q l64-onetickcloud.zip -d "$HOME/.kx/mod/kx"

The installed module is under:

$HOME/.kx/mod/kx/onetickcloud/

Note

Extract the complete release archive, including all files and subdirectories.

If the module fails to load on macOS, refer to Module load fails on macOS.

Configure access

Release archives contain demonstration credentials that provide limited access to OneTick sample data. You do not need to configure credentials to run the example in this quickstart.

To configure access to your OneTick account, obtain the endpoint URLs and OAuth 2.0 client credentials from your OneTick administrator. Set them before starting q:

export OTP_HTTP_ADDRESS="https://rest.example.com"
export OTP_ACCESS_TOKEN_URL="https://auth.example.com/realms/example/protocol/openid-connect/token"
export OTP_CLIENT_ID="your-client-id"
export OTP_CLIENT_SECRET="your-client-secret"

Protect your credentials

Do not commit client secrets to source control or include them in logs and support bundles. Follow your organization's process for storing and supplying secrets.

For configuration precedence and session overrides, refer to Configure the module.

Load the module

Start q and import kx.onetickcloud into the .otc namespace:

q).otc:use`kx.onetickcloud

The assignment loads the module interface under the local .otc alias. The examples use this alias to call functions such as .otc.sql_rest; it is not the name of an object in OneTick.

The module displays initialization messages and returns without error when it loads successfully.

Query OneTick sample data

Run a SQL query against the LSE_SAMPLE.TRD table:

q)sql:"select SYMBOL_NAME, TIMESTAMP, TRADE_ID, PRICE, SIZE from LSE_SAMPLE.TRD where SYMBOL_NAME='VOD' and TIMESTAMP >= '2024-01-03 00:00:00 UTC' and TIMESTAMP < '2024-01-04 00:00:00 UTC' limit 10"
q)data:.otc.sql_rest[sql]
q)data
SYMBOL_NAME TIMESTAMP                     TRADE_ID              PRICE   SIZE
--------------------------------------------------------------------------------
VOD         2024.01.03D07:15:10.133000000 "1075835351045197936" 69.76   40000
VOD         2024.01.03D08:00:06.232000000 "911727684223506"     70      184613
VOD         2024.01.03D08:00:06.233000000 "911727684223588"     70.01   140
..

The query selects five columns from the demonstration trade table, filters for the VOD symbol during one UTC day, and returns at most 10 rows.

data is an unkeyed q table. The module removes the internal CALLBACK_ID column before returning it.

Check the result type and row count:

q)type data
98h
q)count data
10

98h is the q type code for a table. The row count matches the SQL limit 10 clause.

Upgrade the module

Stop any q processes using the module. Remove the existing onetickcloud directory, then extract the new archive into the same KDB-X module directory using the installation steps above.

Warning

Extracting a new archive over an existing installation can leave obsolete files in place. Replace the complete onetickcloud directory when upgrading.

Next steps