An interface between Python and q
Project description
PyKX
Introduction
PyKX is a Python first interface to the worlds fastest time-series database kdb+ and it's underlying vector programming language q. PyKX takes a Python first approach to integrating q/kdb+ with Python following 10+ years of integrations between these two languages. Fundamentally it provides users with the ability to efficiently query and analyze huge amounts of in-memory and on-disk time-series data.
This interface exposes q as a domain-specific language (DSL) embedded within Python, taking the approach that q should principally be used for data processing and management of databases. This approach does not diminish the ability for users familiar with q or those wishing to learn more about it from making the most of advanced analytics and database management functionality but rather empowers those who want to make use of the power of kdb+/q who lack this expertise to get up and running fast.
PyKX supports three principal use cases:
- It allows users to store, query, manipulate and use q objects within a Python process.
- It allows users to query external q processes via an IPC interface.
- It allows users to embed Python functionality within a native q session using it's under q functionality.
Users wishing to install the library can do so following the instructions here.
Once you have the library installed you can get up and running with PyKX following the quickstart guide here.
What is q/kdb+?
Mentioned throughout the documentation q and kdb+ are respectively a highly efficient vector programming language and highly optimised time-series database used to analyse streaming, real-time and historical data. Used throughout the financial sector for 25+ years this technology has been a cornerstone of modern financial markets providing a storage mechanism for historical market data and tooling to make the analysis of this vast data performant.
Kdb+ is a high-performance column-oriented database designed to process and store large amounts of data. Commonly accessed data is available in RAM which makes it faster to access than disk stored data. Operating with temporal data types as a first class entity the use of q and it's query language qsql against this database creates a highly performant time-series analysis tool.
q is the vector programming language which is used for all interactions with kdb+ databases and which is known both for its speed and expressiveness.
For more information on using q/kdb+ and getting started with see the following links:
Installation
Installing PyKX using pip
Ensure you have a recent version of pip:
pip install --upgrade pip
Then install the latest version of PyKX with the following command:
pip install pykx
To install a specific version of PyKX run the following command replacing <INSERT_VERSION> with a specific released semver version of the interface
pip install pykx==<INSERT_VERSION>
Warning: Python packages should typically be installed in a virtual environment. This can be done with the venv package from the standard library.
PyKX License access and enablement
Installation of PyKX via pip provides users with access to the library with limited functional scope, full details of these limitations can be found here. To access the full functionality of PyKX you must first download and install a kdb+ license, this can be achieved either through use of a personal evaluation license or receipt of a commercial license.
Personal Evaluation License
The following steps outline the process by which a user can gain access to an install a kdb Insights license which provides access to PyKX
- Visit https://kx.com/kdb-insights-personal-edition-license-download/ and fill in the attached form following the instructions provided.
- On receipt of an email from KX providing access to your license download this file and save to a secure location on your computer.
- Set an environment variable on your computer pointing to the folder containing the license file (instructions for setting environment variables on PyKX supported operating systems can be found here.
- Variable Name:
QLIC
- Variable Value:
/user/path/to/folder
- Variable Name:
Commercial Evaluation License
The following steps outline the process by which a user can gain access to an install a kdb Insights license which provides access to PyKX
- Contact you KX sales representative or sales@kx.com requesting a trial license for PyKX evaluation. Alternately apply through https://kx.com/book-demo.
- On receipt of an email from KX providing access to your license download this file and save to a secure location on your computer.
- Set an environment variable on your computer pointing to the folder containing the license file (instructions for setting environment variables on PyKX supported operating systems can be found here.
- Variable Name:
QLIC
- Variable Value:
/user/path/to/folder
- Variable Name:
Note: PyKX will not operate with a vanilla or legacy kdb+ license which does not have access to specific feature flags embedded within the license. In the absence of a license with appropriate feature flags PyKX will fail to initialise with full feature functionality.
Supported Environments
KX only officially supports versions of PyKX built by KX, i.e. versions of PyKX installed from wheel files. Support for user-built installations of PyKX (e.g. built from the source distribution) is only provided on a best-effort basis. Currently, PyKX provides wheels for the following environments:
- Linux (
manylinux_2_17_x86_64
) with CPython 3.8-3.11 - macOS (
macosx_10_10_x86_64
) with CPython 3.8-3.11 - Windows (
win_amd64
) with CPython 3.8-3.11
Dependencies
Python Dependencies
PyKX depends on the following third-party Python packages:
pandas>=1.2, < 2.0; python_version=='3.8'
pandas>=1.2, < 2.2.0; python_version>'3.8'
numpy~=1.22, <2.0; python_version<'3.11'
numpy~=1.23, <2.0; python_version=='3.11'
numpy~=1.26, <2.0; python_version=='3.12'
pytz>=2022.1
toml~=0.10.2
dill>=0.2.0
They are installed automatically by pip
when PyKX is installed.
PyKX also has an optional Python dependency of pyarrow>=3.0.0
, which can be included by installing the pyarrow
extra, e.g. pip install pykx[pyarrow]
When using PyKX with KX Dashboards users will be required to install ast2json~=0.3
this can be installed using the dashboards
extra, e.g. pip install pykx[dashboards]
When using PyKX Streaming users may require the ability to stop processes initialized in a now unavailable process to facilitate this PyKX can make use of psutil
this can be installed using the streaming
extra, e.g. pip install pykx[streaming]
When using Streamlit users will be required to install streamlit~=1.28
this can be installed using the streamlit
extra, e.g. pip install pykx[streamlit]
Warning: Trying to use the pa
conversion methods of pykx.K
objects or the pykx.toq.from_arrow
method when PyArrow is not installed (or could not be imported without error) will raise a pykx.PyArrowUnavailable
exception.
Optional Non-Python Dependencies
libssl
for TLS on IPC connections.libpthread
on Linux/MacOS when using thePYKX_THREADING
environment variable.
Building from source
Installing Dependencies
The full list of supported environments is detailed here. Installation of dependencies will vary on different platforms.
apt
example:
apt-install python3 python3-venv build-essential python3-dev
yum
example:
yum install python3 gcc gcc-c++ python3-devel.x86_64
Windows:
- Python
- Build Tools for Visual Studio.
- dlfcn-win32. Can be installed using Vcpkg.
To install the above dependencies, you can run the w64_install.ps1
script as an administrator:
cd pykx
.\w64_install.ps1
Building
Using a Python virtual environment is recommended:
python3 -m venv pykx-dev
source pykx-dev/bin/activate
Build and install PyKX:
cd pykx
pip3 install -U '.[all]'
To run PyKX in licensed mode ensure to follow the steps to receive a Personal Evaluation License
Now you can run/test PyKX:
(pykx-dev) /data/pykx$ python
Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pykx
>>> pykx.q('1+1')
pykx.LongAtom(pykx.q('2'))
Testing
Contributions to the project must pass a linting check:
pflake8
Contributions to the project must include tests. To run tests:
export PATH="$PATH:/location/of/your/q/l64" # q must be on PATH for tests
export QHOME=/location/of/your/q #q needs QHOME available
python -m pytest -vvv -n 0 --no-cov --junitxml=report.xml
PyKX Licenses
This work is dual licensed under Apache 2.0 and the Software License for q.so and users are required to abide by the terms of both licenses in their entirety.
Community Help
If you have any issues or questions you can post them to community.kx.com. Also available on Stack Overflow are the tags pykx and kdb.
Customer Support
- Inquires or feedback:
pykx@kx.com
- Support for Licensed Subscribers: support.kx.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pykx-3.0.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 8.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdcda7924acebc503e0f723ddeb2a80520e5c7c6cc988b50001c159f878c13e3 |
|
MD5 | 4ebdb789056c7cc690d85606867848dc |
|
BLAKE2b-256 | 8c6dd2788aa83e67706950ac4e8ffc3ea2fe1db1c8ac91414eb3b7dc107a48d0 |
File details
Details for the file pykx-3.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 12.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49b77308c974fa1352851fa3817990998b4b79beb5a8c2a1f4ae52ea7b77213d |
|
MD5 | 6f1207a1057c2a889e414387c759f656 |
|
BLAKE2b-256 | eee49b52d163915332089a2d3a16b9aa3a7bbc80f77d64e49b6f41bd2b106437 |
File details
Details for the file pykx-3.0.0-cp312-cp312-manylinux2014_aarch64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp312-cp312-manylinux2014_aarch64.whl
- Upload date:
- Size: 11.9 MB
- Tags: CPython 3.12
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28d9d6bcc2dad777faa308df2f5477b2391341920b6281cb0ab160e2bd1837fc |
|
MD5 | 730b5420f34beb368a21fe53b78b052b |
|
BLAKE2b-256 | cc0dba3e3ac9034733a8005b02b9260411af23ec7175d40ff1fbd249ffdd8eba |
File details
Details for the file pykx-3.0.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 8.2 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46c26f164c6365825480d897dfe52605813519b8e58d20c3a1724089a280edfd |
|
MD5 | 9a960811479044ad58e792c183a1a845 |
|
BLAKE2b-256 | 2f45de8cd4a496ba0503be756c35ca8d89573997346cb1454beeb0a515a725d9 |
File details
Details for the file pykx-3.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 13.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b80e1086b1172e4f8928462fe03ca911a320d4fdb50281b7691c3c4b954ebe8 |
|
MD5 | 40e47cb9ec631247758fe03365cb3a1d |
|
BLAKE2b-256 | 519775dea47e2c785895cb6f95c25d08b8621b498a278e24da8f90cb1139d7e2 |
File details
Details for the file pykx-3.0.0-cp311-cp311-manylinux2014_aarch64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp311-cp311-manylinux2014_aarch64.whl
- Upload date:
- Size: 12.7 MB
- Tags: CPython 3.11
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51add52de012571ae605906a24b448a7450a3633a8b2ccecdf0b646bbabf7f50 |
|
MD5 | ae824bca3c528fc70ae8afd90f52cc89 |
|
BLAKE2b-256 | beb5ed51784057313356e1fbea3bead1630b7ea88f86328fa53df56948558337 |
File details
Details for the file pykx-3.0.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 8.2 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3af843216f94db933efd52a5f0d553703c908d8d3d008dcb0d25876e059937cb |
|
MD5 | 71c5494bf6dd9f3c4bb0d6df815c441c |
|
BLAKE2b-256 | 4e7d9200894852d134882b8749c8c8a593d48d2a8c76e7fb1052be0b5ef311e5 |
File details
Details for the file pykx-3.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.7 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00ccd83e09e9e188622a7439dce93959b3429f446197ebfcc87d874fe197cc57 |
|
MD5 | 63c65b429e65730592a9ac8445be6e54 |
|
BLAKE2b-256 | 16d1c562e85b3d54536bb0d78f43ba64fa7fcf948ffbb945f5cb80b6afe4ad79 |
File details
Details for the file pykx-3.0.0-cp310-cp310-manylinux2014_aarch64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp310-cp310-manylinux2014_aarch64.whl
- Upload date:
- Size: 11.5 MB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35ab4df083647c670c24cb78dbfdcceebe0be4de1c4dde362856b31bd3a6cb72 |
|
MD5 | 26b8a93c6a2cf522ce4b45107c3b6b85 |
|
BLAKE2b-256 | 255149125dcd83445181a14d66d2836da70e62324788223a963065905a4f4c4f |
File details
Details for the file pykx-3.0.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 8.2 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f001a8399c34c8d41cfbe0c465485733943f5828c265c92ad7f5400871a0cf9b |
|
MD5 | 678570d4a01a60fe70ef7805d8ee18bd |
|
BLAKE2b-256 | 1484b58e4e2da115706b03e8c58546aa38d2709cedb5161581b0959278630b3c |
File details
Details for the file pykx-3.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.7 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cf9f8e73f0d082c019a5a0b6d0b47fd2df75e0db903448de4cbd8b6e22b03d1 |
|
MD5 | 2547aa9318f88e0fcec3fd37123e95ce |
|
BLAKE2b-256 | c26e0fdc85b9f0ab711b1736eba6470f2c5a05f44ba9e391a95e0202e78c05f1 |
File details
Details for the file pykx-3.0.0-cp39-cp39-manylinux2014_aarch64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp39-cp39-manylinux2014_aarch64.whl
- Upload date:
- Size: 11.5 MB
- Tags: CPython 3.9
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36366f09e623a43300165039db6c0bdca53d80c398ef540dce641bed1e812ad7 |
|
MD5 | 2bc90a5cf4e66c566b77cb84867757ba |
|
BLAKE2b-256 | 02aa42ddd26e3ad79a213240211f818e76c97a2d3b9b20b90bded8998784c553 |
File details
Details for the file pykx-3.0.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 8.2 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c61002f1382a12b6f52c945c883e6867ea5995e26bf0c6d72181d189bdad3581 |
|
MD5 | 699c64afec64948bc66e7e61db6aeedb |
|
BLAKE2b-256 | fe4cc39e60195a4a641eb3d2dff88239f9becdf50c325fc5ca3f00a62e9b825a |
File details
Details for the file pykx-3.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.8 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47e08d550b7c117b58b09a40b33781d37031f479c3b564a373fb2fbc586230f9 |
|
MD5 | 08ed9396fc2c30d089d4035de6952ce2 |
|
BLAKE2b-256 | f7f332fd4b9a0547e1e00da92a0ff116024a98acd282f1f4b6bf29dc3e439cab |
File details
Details for the file pykx-3.0.0-cp38-cp38-manylinux2014_aarch64.whl
.
File metadata
- Download URL: pykx-3.0.0-cp38-cp38-manylinux2014_aarch64.whl
- Upload date:
- Size: 11.6 MB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a03f950dc9b8664c6794b8d9e1edaec1a5d3aae10355b0ac2dc7f5f83dad4ef7 |
|
MD5 | 8dc687e71bda9957c749019da162d645 |
|
BLAKE2b-256 | 9f9c1380ab8957b3ca2bab8ecb2c2746d28f7fdf84e36242eed177ab550ad3cb |