Package: pykx
PyKXIntroductionPyKX 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 instructionshere.Once you have the library installed you can get up and running with PyKX following the quickstart guidehere.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:An introduction to q/kdb+Tutorial videos introducing kdb+/qInstallationInstalling PyKX usingpipEnsure you have a recent version of pip:pip install --upgrade pipThen install the latest version of PyKX with the following command:pip install pykxTo install a specific version of PyKX run the following command replacing <INSERT_VERSION> with a specific released semver version of the interfacepip 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 enablementInstallation of PyKX via pip provides users with access to the library with limited functional scope, full details of these limitations can be foundhere. 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 LicenseThe following steps outline the process by which a user can gain access to an install a kdb Insights license which provides access to PyKXVisithttps://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 foundhere.Variable Name:QLICVariable Value:/user/path/to/folderCommercial Evaluation LicenseThe following steps outline the process by which a user can gain access to an install a kdb Insights license which provides access to PyKXVisithttps://kx.com/kdb-insights-commercial-evaluation-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 foundhere.Variable Name:QLICVariable Value:/user/path/to/folderNote: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 EnvironmentsKX 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.11macOS (macosx_10_10_x86_64) with CPython 3.8-3.11Windows (win_amd64) with CPython 3.8-3.11DependenciesPython DependenciesPyKX depends on the following third-party Python packages:pandas>=1.2, < 2.2.0numpy~=1.22; python_version<'3.11'numpy~=1.23.2; python_version=='3.11'pytz>=2022.1toml~=0.10.2They are installed automatically bypipwhen PyKX is installed.PyKX also has an optional Python dependency ofpyarrow>=3.0.0, which can be included by installing thepyarrowextra, e.g.pip install pykx[pyarrow]When using PyKX with KX Dashboards users will be required to installast2json~=0.3this can be installed using thedashboardsextra, e.g.pip install pykx[dashboards]When using PyKX Beta features users will be required to installdill>=0.2.0this can be installed using thebetaextra, e.g.pip install pykx[beta]Warning:Trying to use thepaconversion methods ofpykx.Kobjects or thepykx.toq.from_arrowmethod when PyArrow is not installed (or could not be imported without error) will raise apykx.PyArrowUnavailableexception.pyarrowis supported Python 3.8-3.10 but remains in Beta for Python 3.11.Optional Non-Python Dependencieslibsslfor TLS onIPC connections.libpthreadon Linux/MacOS when using thePYKX_THREADINGenvironment variable.Windows DependenciesTo run q or PyKX on Windows,msvcr100.dllmust be installed. It is included in theMicrosoft Visual C++ 2010 Redistributable.Building from sourceInstalling DependenciesThe full list of supported environments is detailedhere. Installation of dependencies will vary on different platforms.aptexample:apt-installpython3python3-venvbuild-essentialpython3-devyumexample:yuminstallpython3gccgcc-c++python3-devel.x86_64Windows:PythonBuild Tools for Visual Studio.dlfcn-win32. Can be installed usingVcpkg.msvcr100.dll. Available inMicrosoft Visual C++ 2010 Redistributable.BuildingUsing a Python virtual environment is recommended:python3-mvenvpykx-devsourcepykx-dev/bin/activateBuild and install PyKX:cdpykx
pip3install-U'.[all]'To run PyKX in licensed mode ensure to follow the steps to receive aPersonal Evaluation LicenseNow you can run/test PyKX:(pykx-dev)/data/pykx$python
Python3.10.6(main,May292023,11:10:38)[GCC11.3.0]onlinux
Type"help","copyright","credits"or"license"formoreinformation.
>>>importpykx
>>>pykx.q('1+1')pykx.LongAtom(pykx.q('2'))TestingContributions to the project must pass a linting check:pflake8Contributions to the project must include tests. To run tests:exportPATH="$PATH:/location/of/your/q/l64"# q must be on PATH for testsexportQHOME=/location/of/your/q#q needs QHOME availablepython-mpytest-vvv-n0--no-cov--junitxml=report.xmlPyKX License access and enablementThis work is dual licensed underApache 2.0and theSoftware License for q.soand users are required to abide by the terms of both licenses in their entirety.Community HelpIf you have any issues or questions you can post them tocommunity.kx.com. Also available on Stack Overflow are the tagspykxandkdb.Customer SupportInquires or feedback:pykx@kx.comSupport for Licensed Subscribers:support.kx.com