Skip to content

kxi-toolkit: Select

Convenience wrapper around the KXI selectTable API.

Provides select_table, a Pythonic interface to .kxi.selectTable that handles argument construction and q expression parsing. Requires PyKX to bridge into the KXI runtime — install with pip install kxi-toolkit[pykx]. Fails gracefully with an ImportError if PyKX is not installed, or with a warning if the KXI runtime is unavailable.

Functions:

select_table

select_table(table, start=None, end=None, where=None, by=None, agg=None, mmap=None)

Query a KXI table via .kxi.selectTable.

Builds the argument dictionary expected by .kxi.selectTable and delegates to PyKX. Only supplied arguments are included in the call so the API applies its own defaults for omitted fields.

Parameters:

  • table (Any) – Table name as a KXI Symbol (or plain string).
  • start (Any) – Start timestamp (inclusive). Mapped to startTS.
  • end (Any) – End timestamp (inclusive). Mapped to endTS.
  • where (Any) – Filter expressions as a list of q expression strings. Each string is parsed with kx.q.parse before being passed to the API. Example: ["sym=`AAPL", "qty>100"].
  • by (Any) – Group-by column or list of columns. Mapped to groupBy.
  • agg (Any) – Aggregation mapping of {output_col: q_expression_string}. Each value is parsed with kx.q.parse. Example: {"totalQty": "sum qty"}.
  • mmap (Any) – Whether to use memory-mapped reads.

Returns:

  • Any – A PyKX Table containing the query result.

Raises:

Example
from kxi_toolkit import select_table

result = select_table(
    table="trades",
    start=start_ts,
    end=end_ts,
    where=["sym=`AAPL"],
    agg={"totalQty": "sum qty"},
)
Back to top