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 – Query a KXI table via
.kxi.selectTable.
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 KXISymbol(or plain string). - start (
Any) – Start timestamp (inclusive). Mapped tostartTS. - end (
Any) – End timestamp (inclusive). Mapped toendTS. - where (
Any) – Filter expressions as a list of q expression strings. Each string is parsed withkx.q.parsebefore being passed to the API. Example:["sym=`AAPL", "qty>100"]. - by (
Any) – Group-by column or list of columns. Mapped togroupBy. - agg (
Any) – Aggregation mapping of{output_col: q_expression_string}. Each value is parsed withkx.q.parse. Example:{"totalQty": "sum qty"}. - mmap (
Any) – Whether to use memory-mapped reads.
Returns:
Any– A PyKXTablecontaining the query result.
Raises:
ImportError– IfPyKXis not installed.
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"},
)