Skip to content

type-null/ML-in-kdb-q

Repository files navigation

Installation Guide for q

Normal download and installation visit here.

You may request academic license (not necessary).

I installed the q with a machine-learning environment setup.

Download jupyterq via Anaconda

Jupyter kernel for kdb+ introduction: https://code.kx.com/q/ml/jupyterq/

kdb kernel

The three Kx packages can be downloaded from anaconda.org/kx:

  • kdb
  • embedpy
  • jupyterq

These are available for Linux, Windows and macOS.

They are in a dependency tree.

- jupyterq
  - embedpy
    - kdb

So we use command

conda install -c kx jupyterq

Before starting q, run the following commands:

source deactivate base
source activate base

When you first run q it will ask for your name and email for generating license.

Install rlwrap

Call kdb+ within the rlwrap command, which will allow you to call back and edit previous lines.

Use homebrew to install rlwrap

brew install rlwrap

Verify installation. Type command to see the version of rlwrap if installed successfully.

rlwrap -v

Add q alias to bash profile

Define q as a command alias, allowing you to invoke kdb+ without specifying the path to it.

Use vim or IDE of your choice to open ~/.bash_profile:

vim ~/.bash_profile
open -a "Sublime Text" ~/.bash_profile

append the following line

alias q='QHOME=~/anaconda3/q rlwrap -r ~/anaconda3/q/m64/q'

and save it. Start a new Terminal session, or tell Bash to use the revised profile:

source ~/.bash_profile

Confirm successful installation

Type q in Terminal and hit enter.

Now you can type an expression and recall it using the up-arrow key.

q)til 6 / first 6 integers
0 1 2 3 4 5
q)til 6 / first 6 integers
0 1 2 3 4 5
q)\\
$

Run in Matlab

Datafeed Toolbox™ functions enable you to create a Kx Systems, Inc. kdb+ database connection and retrieve data from and write data into a Kx Systems, Inc. kdb+ database.

To retrieve data, first create a Kx Systems, Inc. kdb+ database connection by using the kx function, and then use the fetch function. To write data into the database, use the write function.

For details about the interface, see MATLAB client for kdb+.

For macOS, you need to set PATH for Finder-launched applications .

PATH = getenv('PATH');
setenv('PATH', [PATH ':/Users/<usename>/anaconda3/q/m64')];

Download java support files as MATLAB client for kdb+ suggests.

javaaddpath /home/myusername/jdbc.jar
javaaddpath /home/myusername/c.jar

We can confirm that we’ve added this successfully using the javaclasspath function. In Matlab command window:

>> javaclasspath
    STATIC JAVA PATH
...
    /opt/matlab/2015b/java/jar/toolbox/stats.jar
    /opt/matlab/2015b/java/jar/toolbox/symbol.jar

    DYNAMIC JAVA PATH

    /home/myusername/jdbc.jar
    /home/myusername/c.jar

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages