Skip to main content

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

  1. Visit https://kx.com/kdb-insights-personal-edition-license-download/ and fill in the attached form following the instructions provided.
  2. On receipt of an email from KX providing access to your license download this file and save to a secure location on your computer.
  3. 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

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

  1. Contact you KX sales representative or sales@kx.com requesting a trial license for PyKX evaluation. Alternately apply through https://kx.com/book-demo.
  2. On receipt of an email from KX providing access to your license download this file and save to a secure location on your computer.
  3. 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

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.3; 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
  • requests>=2.25.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 the PYKX_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:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pykx-3.0.1-cp312-cp312-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.12 Windows x86-64

pykx-3.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.5 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pykx-3.0.1-cp312-cp312-manylinux2014_aarch64.whl (11.9 MB view details)

Uploaded CPython 3.12

pykx-3.0.1-cp311-cp311-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.11 Windows x86-64

pykx-3.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pykx-3.0.1-cp311-cp311-manylinux2014_aarch64.whl (12.7 MB view details)

Uploaded CPython 3.11

pykx-3.0.1-cp310-cp310-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.10 Windows x86-64

pykx-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pykx-3.0.1-cp310-cp310-manylinux2014_aarch64.whl (11.5 MB view details)

Uploaded CPython 3.10

pykx-3.0.1-cp39-cp39-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.9 Windows x86-64

pykx-3.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pykx-3.0.1-cp39-cp39-manylinux2014_aarch64.whl (11.5 MB view details)

Uploaded CPython 3.9

pykx-3.0.1-cp38-cp38-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.8 Windows x86-64

pykx-3.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.9 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pykx-3.0.1-cp38-cp38-manylinux2014_aarch64.whl (11.6 MB view details)

Uploaded CPython 3.8

File details

Details for the file pykx-3.0.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pykx-3.0.1-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/6.0.1 CPython/3.10.15

File hashes

Hashes for pykx-3.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 29448ef6181b11374f489ea7a466955e9f7da6741d992c01f0f4a35732ffc54b
MD5 c80d9b69662374f0ad21969c7699dd3f
BLAKE2b-256 af7da1e11b8fc92cdac9a88b5dd8cde30354aad92d10fa32f96555934c25de79

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a2ca5da7f0698587b5e255602a353bb16091b75e8f57b69b3bf26cd4720c117
MD5 f2ad1720f1b526bd92f2589c3bcf3cc3
BLAKE2b-256 410c75abf7355e0b9efec80ceb3c08e1420a885e655356ab2694bf7ed4c5b855

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8dff9b02553c320931c615f71c0a495bee2c6756dc5523829e1af127eff762d2
MD5 ed1ae9616307336bb52a550912546036
BLAKE2b-256 55f4b763df5a09b1ccb99aa7ee7c8bddb102cf81d17db97c4240ee50aa328cdb

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pykx-3.0.1-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/6.0.1 CPython/3.10.15

File hashes

Hashes for pykx-3.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c1fbbe3853e962906e738cb65d62c8449089c9cfcb040bafa50ea5fad4cd4689
MD5 5428d6b8a9fcaf445c90cd2721b7dafc
BLAKE2b-256 79860ddcff73ba4c997106fc0fb71e6b80de876e7761c664db27f285221d6b71

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bef92d99bf7202285708df447f514408ce01d0ea9ab6eb610a3fd05879ebef5c
MD5 46b4f3a876be141b1fea9c5d4a5510e3
BLAKE2b-256 db2dca345ba75bab92f2a3157567aea1196ee7eff0c09edaf98675919bf3eeb9

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ba43897bd324a9ac14760fde92cac8c99e08557d22426f10bb3085a8fb054189
MD5 741c3b58f1bc5af135913ec9a6d031ed
BLAKE2b-256 7c5d8720b05b79fed453b5ac7489715af03dd809e8ea097e0fdff5fa42fabc4f

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pykx-3.0.1-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/6.0.1 CPython/3.10.15

File hashes

Hashes for pykx-3.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c0053d31b21ba58a7b3b801404f96763a3aa2bc7f0b639b8f8123d51eddc6d03
MD5 72056d40514f4a01b21e80b00741d092
BLAKE2b-256 8afc49e24bf6b1adccd84d048854ee5fb8f3f77479ac6b8d4563f7b7036dda95

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 baa66df33c9dfd0fe5399ca2e6957a53b72494d9b5d43e3f9e5cb7a40e6f84de
MD5 05b197cbf9868abdf6b059ecfee25889
BLAKE2b-256 083eabcdfed3ce9ee47d6be35602d76c3d18fad67c89d8af8f8196f66ff496ca

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f1ce585cab239134f1897ddabf945a1e06a7382dce4f31499f1bd0bbb0c010e0
MD5 3772369fc0df6d377292ec92169eaecc
BLAKE2b-256 daad0cc8680e34d033d82060b535fa435415548c135c93372dc55eb3706fc872

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pykx-3.0.1-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/6.0.1 CPython/3.10.15

File hashes

Hashes for pykx-3.0.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 db2da0f83317ce6994a1d8cc085b9acadcfe96bd106ec53b74544e7de865210f
MD5 3ed29971c1196c8ae9688caf9d9a634b
BLAKE2b-256 cc7622d0870da39ab7ef96259951e0625d2fd7bc4b25f12a5fc7152ff5e06b46

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d271ad2805e32e0166071f27f052e54790b5b078413d1bebbed9d7e678a6a574
MD5 ddd6dd2e224cc39ed47cf41805ad5c7e
BLAKE2b-256 c51b72a26899da442abb4635959f9e53d42fafe318c4309c8695ed0543531b5f

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp39-cp39-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4608db20f764b47bb8234cba833c2649042202a2725f5c562b1471d3eabb4833
MD5 dce1dd04404f9fa5174d9467ee648416
BLAKE2b-256 c8aaf84b07ce49182d7be455453a73284550df6ba6436e0d4b32b8396b1087d5

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pykx-3.0.1-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/6.0.1 CPython/3.10.15

File hashes

Hashes for pykx-3.0.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 80a82d3b9ae749cce2f878ae45d34cde80a4ff553174a56b10ee98c1d9d473b4
MD5 515132dc58c99102d282b39edcf2475b
BLAKE2b-256 fb665f4ec57b315ae64789e925d6023b8092e8ee72a1b3e56038a8101086b54e

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 168786db8884d8e27b4f3f94d35a5af61fc10efc4bfe2033e4c7f272ae74a55d
MD5 11b11b3509b4dc2e54dd45e92110fe4c
BLAKE2b-256 d3315f41fd4608a1055d7077e500dcd8a760238c08f607abf1a3240cac02915e

See more details on using hashes here.

File details

Details for the file pykx-3.0.1-cp38-cp38-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pykx-3.0.1-cp38-cp38-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d4b56e8f77d7df163bc683a7c04ccc47a079c35d174dd4e0593a0957e0834579
MD5 86b30d6a49b006bb1af884007bf97420
BLAKE2b-256 6ae6cc701c563352bdc4c0edbab5d4e50c774e0cfa395185e51c748b5f7e9ad5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page