Why kdb+ Still Matters
kdb+ is a column-oriented in-memory database built specifically for time series. Created by Arthur Whitney at Kx Systems in 1993, it has been the dominant time-series database in investment banking for decades. Goldman Sachs, JPMorgan, Morgan Stanley, Citigroup, Barclays, Deutsche Bank, and most major hedge funds use kdb+ for tick data storage, real-time analytics, and time-series research.
In 2026, kdb+ faces increasing competition from open-source alternatives (ClickHouse, QuestDB, TimescaleDB, polars + parquet workflows), but it remains entrenched at top financial institutions. Knowing kdb+ remains a real differentiator for quant developer and quant researcher roles at sell-side banks and many hedge funds.
This tutorial introduces kdb+ and its query language q at a practical level. For broader engineering context, see our big data pipelines in finance and quant developer career guide.
Why kdb+ is Different
Three things make kdb+ uniquely suited to financial time series:
1. Column-oriented storage
Each column is stored as a contiguous array. For typical time-series queries (compute the average of a specific column over a time range), this layout is dramatically faster than row-oriented databases. Cache misses are minimised; SIMD instructions can process multiple values per CPU cycle.
2. Native time-series operations
kdb+ has built-in operations for time-series-specific tasks: as-of joins, time-bucket aggregations, sliding-window calculations. In SQL, these require complex window functions; in q, they're one-liners.
3. Speed
A well-tuned kdb+ database can query trillions of rows of historical tick data in seconds. Some teams use it as their entire research database; others use it as a caching layer in front of slower backing stores.
Installing kdb+
Free for personal/non-commercial use:
- Download from kx.com (Personal Edition).
- Install (just unzip; no installer needed).
- Set environment variable QHOME to the install directory.
- Run:
q
You'll see the q REPL:
KDB+ 4.1 2024.10.31 Copyright (C) 1993-2024 Kx Systems
q)
The q Language - Hello World
q is concise to the point of being terse. A few examples to get the feel:
q)1+2 3 q)sum 1 2 3 4 5 15 q)x: 1 2 3 4 5 q)x*2 2 4 6 8 10 q)avg x 3f
Variables are assigned with colon. Most operations work elementwise on vectors. The default number type is float (suffix f).
Tables in q
Tables are columns of equal length:
q)trade: ([] symbol: `AAPL`AAPL`MSFT`AAPL`MSFT; time: 09:30:00 09:30:01 09:30:01 09:30:02 09:30:02; price: 150.0 150.5 280.0 151.0 281.0; size: 100 200 50 150 75) q)trade symbol time price size -------------------------- AAPL 09:30:00 150 100 AAPL 09:30:01 150.5 200 MSFT 09:30:01 280 50 AAPL 09:30:02 151 150 MSFT 09:30:02 281 75
The ``` prefix denotes symbols (interned strings, fast for keys).
Basic Queries (q-SQL)
q has its own SQL-like syntax. Examples:
Select all
q)select from trade symbol time price size -------------------------- AAPL 09:30:00 150 100 ...
Filter
q)select from trade where symbol=`AAPL symbol time price size -------------------------- AAPL 09:30:00 150 100 AAPL 09:30:01 150.5 200 AAPL 09:30:02 151 150
Aggregate
q)select avg price, sum size by symbol from trade symbol| price size ------| ---------------- AAPL | 150.5 450 MSFT | 280.5 125
Time-bucket aggregation
q)select avg price by symbol, 5 xbar time.minute from trade symbol minute| price -------------| ----- AAPL 09:30 | 150.5 MSFT 09:30 | 280.5
xbar floors values to a bucket. 5 xbar 09:30:01 = 09:30. Used heavily in time-series analytics.
Reading Data
From CSV
q)t: ("SDSI"; enlist ",") 0:`:trades.csv // Format string: S=symbol, D=date, S=symbol, I=int // 0: is the file read operator
From a kdb+ binary file
q)t: get `:trades_db
Save a table
q)`:my_table set trade
As-Of Joins (the killer feature)
The classic financial use case: for each trade, what was the bid/ask at that moment?
q)quote: ([] sym: `AAPL`AAPL`MSFT`AAPL; time: 09:30:00 09:30:01 09:30:01 09:30:02; bid: 149.95 150.45 279.95 150.95; ask: 150.05 150.55 280.05 151.05) // Sort both by sym then time (required for asof) q)`sym`time xasc `trade q)`sym`time xasc `quote // As-of join: for each trade, get the most recent quote q)aj[`sym`time; trade; quote] symbol time price size bid ask ------------------------------------- AAPL 09:30:00 150 100 149.95 150.05 AAPL 09:30:01 150.5 200 150.45 150.55 AAPL 09:30:02 151 150 150.45 150.55 // No new quote at 09:30:02 MSFT 09:30:01 280 50 279.95 280.05 MSFT 09:30:02 281 75 279.95 280.05
This join would be a complex window function in SQL. In q, it's one operator. aj (asof join) is the default. wj (window join) supports range-based joins.
Time Series Functions
A few common time-series operations in q:
Moving average
q)5 mavg trade[`price]
Difference (e.g., for returns)
q)deltas trade[`price] 0n 0.5 0n 0.5 0n // first value is null
Rolling sum
q)5 msum trade[`size]
Forward-fill nulls
q)fills 1 0n 3 0n 5 1 1 3 3 5
Working with kdb+ from Python
For most users, q-from-python via the qpython library is the practical workflow - keep your data in kdb+ for speed, do analysis in Python:
pip install qpython
from qpython import qconnection with qconnection.QConnection(host='localhost', port=5000) as q: result = q.sendSync('select avg price by symbol from trade') print(result)
This sends a q query to a running kdb+ instance and returns a NumPy/pandas-friendly result.
Where kdb+ Fits in 2026
Strong fit
- Sell-side bank quant teams (Goldman, JPM, Morgan Stanley, Barclays, Deutsche, UBS) - kdb+ is entrenched
- HFT and market makers with serious tick data storage needs
- Hedge fund research teams with multi-trillion-row historical data
- Real-time analytics on streaming market data
Less compelling fit (in 2026)
- Greenfield retail / small fund work - polars + parquet or QuestDB are now competitive
- Most ML/AI workflows - the Python ecosystem is dominant
- Cloud-first architectures - kdb+ historically struggles with cloud-native deployment
Where to learn more
- Q for Mortals (Jeffrey Borror) - the standard introductory book, free online at code.kx.com/q4m3
- The official Kx tutorials at kx.com
- The Stack Overflow [kdb] tag - active Q&A community
Should You Learn kdb+?
Yes if:
- You're targeting sell-side bank quant roles (Goldman Strats, JPM QR, Morgan Stanley, Barclays QA, Deutsche)
- You're targeting HFT / market-making firms with serious tick data infrastructure (HRT, Citadel Securities, Tower)
- You're a quant developer who wants a real differentiator on your CV
Probably not if:
- You're a researcher who already has Python + Pandas/Polars + Parquet workflows that work
- You're targeting modern fintech or hedge funds that haven't standardised on kdb+
- You're early in your quant journey - learn Python first
For broader career context:
Skip the £25k programme - try the alternative
Master's programmes are slow and expensive. Quantt is a self-paced alternative built around the actual skills firms hire for: Python, mathematics, derivatives pricing, options Greeks and live trading-system design. 50+ courses, interactive coding tests, and the same end-state as a one-year MFE - in your evenings.
No prerequisites - start at any level