Skip to content
All library documents

Alternatives to kdb+ for Time-Series Market Data

Article Quant Q&A · Author: Peter Peter

Summary

The discussion surveys ways to store and query large financial time series without relying on kdb+. Options include memory-mapped binary files, Python with Pandas and PyTables, columnar databases such as Vertica and MonetDB, time-series databases, and newer tools such as ClickHouse, QuestDB, ArcticDB, and DuckDB. Several answers argue that a database may be unnecessary when structured flat files meet the workload; others describe SQL databases and clustered systems for larger shared datasets.

The evidence is anecdotal and varies by workload. Contributors report file-reading benchmarks, large row counts, and high write rates, but the thread does not provide a controlled comparison across systems or a single winner. Choice depends on query patterns, ingestion, operational effort, developer experience, hardware, and licensing. Claims reflect different dates and individual experience, so current capabilities and performance should be verified against the intended dataset and workload.

Key ideas

  • Memory-mapped binary files can provide fast sequential access for backtests.
  • Column-oriented databases can support large time-series datasets and analytical queries.
  • Pandas-based tools, SQL databases, and dedicated time-series systems offer different trade-offs in cost and developer experience.
  • A plain structured file format may be sufficient when the workload does not require database services.
  • Reported performance figures are anecdotal and should not be treated as a general benchmark.

Tags

Full text
# Is there any thing out there as a substitute for KDB?


# Is there any thing out there as a substitute for KDB?












thanks a lot for your discussions on the original post.

following your suggestions, let me re-phrase a bit :

kdb is known for its efficiency, and such efficiency comes at a terrible price. However, with computational power so cheap this days, there must be a sweet spot where we can achieve a comparable efficiency of data manipulation, at a more reasonable cost.

For instance, if a KDB license cost a small shop $200K per year (I dont know how much it actually cost, do you know?), maybe there is a substitute solution: e.g., we pay 50K to build a decent cluster, storing all data onto a network file system, and parallelize all the data queries. This solution might not be as fast or as elegant as KDB, but it would be much more affordable and most important -- you take full control of it.

what do you think? is there anything like this?

## Answer by thomas - discretelogics (score 23)

https://quant.stackexchange.com/a/3209

At discretelogics we just released a file format to store time series in flat files called "TeaFiles". In addition to raw data they can store the binary item layout and a description of the contents.

C#, C++, Python APIs are available open source, licensed under the GPL, see discretelogics.com/teafiles/

Using memory mapping, read performance reaches that of in-memory array processing for sequential usage of a file, as is the case for back testing.

The C# API at Codeplex holds micro benchmarks. Summing up a file with a single 8 byte double reaches 500 million operations per second on an older test machine. Using a Tick Item with int64 / double / int for Time/Price/Volume is 100 million operations.

## Answer by mollmerx (score 22)

https://quant.stackexchange.com/a/11029

As of April 2014, the 32-bit version of kdb+ is now free to try.

This free version may not be used in production systems.

The only technical limitation vs. the 64-bit version is that you can only address up to 4GB of memory per process.

## Answer by chrisaycock (score 17)

https://quant.stackexchange.com/a/7073

You could look into Pandas, a Python library that integrates with PyTables. It was created by someone at AQR and has some similar features as KDB.

## Answer by Summer_More_More_Tea (score 17)

https://quant.stackexchange.com/a/11196

I don't like KDB+/q. For KDB+ experts, I am not picking a fight. The following is just my own understanding on KDB+ and TimeSeries Database. You're warmly welcome to correct me if anything wrong in your eyes :).

First of all, during my near one year's KDB+/q development experience, I never ever find a paper based benchmark result indicating KDB+/q significantly out performs other storage system in time. By storage system, I don't limit the scope to disk based RDBMS. So I don't know why everybody in quant finance is talking about KDB+ and impressed by its efficiency without data backing their points.

Second, I once talked with an Oracle Certificated DBA about KDB+. From my description, the first word he came up is an in-memory cache not even a full fledge database. Maybe he is right to some extent, isn't he?

Next is the so-called TimeSeries. More than one manager advocating KDB+ from different positions and companies talked to me KDB+ is a TimeSeries Database. However, I don't think TimeSeries is a feature of KDB+, whose real feature is the column oriented storage engine. That is to say with a column oriented storage engine, that KDB+ is friendly to store TimeSeries data. While in these days, column oriented storage engine does not belong to KDB+ exclusive. For traditional RDBMS, like MySQL, you can also find corresponding column storage engines in the open source communities.

The last and the most important, I want to talk about the developer friendliness. KDB+ is distributed along with a DSL, which is q. q is very developer unfriendly. When an error encountered, it just raise the error type, without any line information for you to anchor, which increase the difficulty to bug fixing and code maintenance.

Alternatives to KDB+ I can come up with:

- to give the system column oriented storage, a traditional K-V store works, even a column storage backed RDBMS;

- for the in-memory feature, a lot of open source implementation of in-memory cache, like redis, memcached, etc.

The key feature for the alternative, I think, is that the API is written in standard C/C++. You could have a lot of utilities to ease your development.

## Answer by alpha (score 12)

https://quant.stackexchange.com/a/3169

KDB is useful for two reasons: - Storage of data; and easy access to the data (i.e. querying ticks..etc) - Rich query language that supports many Quant functions

however; what KDB does not do well; is the quant query language.

I have evaluated KDB, Matlab, and R. So far R is the winner.

I have not found any fast solution for storing and retrieving data; compared to using flat binary files; which are divided by month for ease of acces. My app can read 1 million of tick data in 3 seconds; and do backtesting accordingly.

for retail traders; i suggest you use flat files (binary instead of text; for quick read/write). MT4 data structure is a good example to follow.

It is cheap, free, and fast!!!

## Answer by John at TimeStored (score 12)

https://quant.stackexchange.com/a/16260

We've created a roundup of the top column-oriented database systems: http://www.timestored.com/time-series-data/column-oriented-databases

This includes kdb+ and some open source alternatives.

Open: InfluxDB, Java Chronicles, OpenTSDB, KairosDB

Closed: oneTick, McObject, Teradata Database, vectorwise, sybase, vertica

We have done some initial work at benchmarking common time-series queries and found open source monetDB to be particularly fast...we will hopefully be able to publish some of those results at a later date.

## Answer by Suminda Sirinath S. Dharmasena (score 9)

https://quant.stackexchange.com/a/12744

Have a look at Kona which is a FOSS project trying to be compatible. Also Tom Szczesny has done some work on its predecessors namely A. I hope this helps.

Also if you are not looking for a perfect substitute you can have a look at other Time Series Databases like InfluxDB, Java Chronicles, OpenTSDB, KairosDB which are all Open Source. There are commercial ones as well out of which OneTick is targeted at Tick Data management.

## Answer by ThatDataGuy (score 6)

https://quant.stackexchange.com/a/53406

At the risk of reopening an old question, I thought that I would offer my experience.

I worked for a competitor of Man AHL (who created artic). We used a columnar database called HP Vertica. Its not free unfortunately. We used it as a huge time series database for many use cases. We had one cluster of 3 fairly powerful machines that gave us redundancy if one failed, and had tables with over 100bn rows without issues. It is SQL compliant, and ACID compliant. There were tweaks that could be made to control table/column compression & distribution and replication.

It has great support for datawarehouse operations, like fast ingestion and deferrable constraints.

It did helpful things like auto-normalisation of low cardinality columns etc - ie, one could control the logical and physical schema quite precisely and easily. We could run a select distinct of a single column over 130bn+ rows in less that 10ms. We used it for time series storage (daily and tick) with one observation per row (ie, one tick/close etc per row).

We were able to build some interesting patterns:

- We could store all incoming data against source identifiers (eg, bloomberg ticker), and then pre-materialize the symbology joins vs our internal identifiers.

- We could store all versions of a tick and pre-materialize the filter for only the latest values.

- We wrote a batch job that could copy entire SQL server databases directly into the data warehouse - with automatic handling of nice columns / tables etc. This made dealing with legacy / small / complex datasets very nice as now you could join all enterprise schemas over a single SQL connection. The data scientists used that a LOT.

We were able to do that over the entire dataset of 20k+ symbols * 20+ years of tick data as a series of daily batch runs. This made it very easy to manage the dataset for operators, as they could write selects and deletes using the standard SQL that we all love.

The jdbc driver was also pretty good and offered all the usual semantics and datatypes. At one point I also hooked it up to an apache Spark cluster of 256 cores and managed to achieve a parallel write over jdbc to the same destination table of over 1.2m rows per second (including the commit).

The developer experience was great as it just mainly worked as a massively powerful RMDBS with a lovely SQL experience. Vertica / HP has invested a great deal of time in providing many useful helper functions (time & date, and analytical functions) and the overall feeling was quite similar to PostgreSQL (which is a good thing).

Overall, a nice way to achieve horizontal scalability with little required of the developer or the DBA. You just need your cheque book.

Nowadays, even this approach is probably out of data now that we have things like (really) fast SSDs, cheaper and larger RAM capabilities (epyc rome supports 4TB ram on a single machine!), SPARK, and better tooling around NoSQL implementations. We also have great new initiatives like TimeScaleDB that is FOSS. Combine FOSS with the short setup times of modern hardware on public cloud and you could probably iterate to something similar for little upfront time and money.

## Answer by Newskooler (score 6)

https://quant.stackexchange.com/a/63968

The only thing which comes close to kdb in my opinion is QuestDB.

They are one of the few projects as a TSDB which have speed as a priority. They recently added out-of-order inserts which allowed them to benchmark agains some of the other TSDBs out there and the results were a quite impressive 1.4 millions writes per second (source).

I have been using it (having switched from Influx) and so far it's the best thing I have found.

## Answer by Ari (score 4)

https://quant.stackexchange.com/a/35083

Recent benchmarks of KDB+ vs. other big data technologies, Kdb still comes out on top 5, especially considering hardware costs for this particular data set.

[1.1 Billion Taxi Rides on kdb+/q & 4 Xeon Phi CPUs] http://tech.marksblogg.com/billion-nyc-taxi-kdb.html

## Answer by MK Lee (score 3)

https://quant.stackexchange.com/a/16093

Lots of people focus on data storage ability and compare KDB with other SQL/query-based databases. Such comparison is like considering "Is a Ferrari good for running a bus route?"

KDB+ is capable of manipulating and querying large data set. The performance is fast (in comparison to most RDBMS) due to its column based storage, but it's not her strongest suit. In fact, it could become a serious pain if the query is not well written or when the server just doesn't have enough memory. From my experience, lots of KDB applications do not even host Realtime/Historical databases.

With her simple messages publish/subscribe mechanism and flexible IPC calls, one could build complex event processing engines (and even a network of engines) to operate on these time series data easily. Its performance can easily outmatch other engines written in Java/C due to Q vector processing and loads of functions that tailored made for time series data.

## Answer by Bonaparte (score 2)

https://quant.stackexchange.com/a/14336

One of the reasons q/kdb+ is attractive for tick data is that it can process data tick by tick as well as using the SQL-like query language. You'll read elsewhere that it is a columnar database that uses the vector processor on modern CPUs for noticeably faster throughput.

The only system I've used that can process a tick-feed like q/kdb+ is Esper. It is very difficult to work with because it's an embedded language invoked by an Esper runtime environment within a JVM. There are extra tools available at a fee.

It is possible now to use columnar datastores with Spark/Hadoop: Parquet.

I've used q/kdb+ extensively. The licence changes are really good, I can now use it as part of my toolkit at work and use it within business processes. If you persevere with it, you do appreciate it is an amazing system.

## Answer by Sergei Rodionov (score 2)

https://quant.stackexchange.com/a/20807

Axibase Time Series Database is free on a single node regardless of RAM, CPU, disk. You can store trades, Level 1 quotes, order book statistics, day/auction summaries and reference data for instruments of various types.

Time precision is microseconds.

Supports SQL with various functions for filtering by trading calendar, auction stages, indices etc.

```
SELECT datetime, symbol, close(), vwap()
  FROM atsd_trade
WHERE in_index('<index-name>')
  AND in_session(DAY, CLOSING)
  AND datetime BETWEEN '2021-01-01' AND '2021-01-15' EXCL
GROUP BY exchange, class, symbol, PERIOD(1 DAY)
```

(I work Axibase)

## Answer by xgdgsc (score 2)

https://quant.stackexchange.com/a/27662

man-group/ArcticDB: High performance datastore for time series and tick data seems a good alternative for time series and tick data. It is built upon mongodb.

## Answer by Noel (score 2)

https://quant.stackexchange.com/a/30620

If you're looking for a columnar store alternative, have a look at Druid.io

Druid is a good fit if you are after 1. fast aggregations and searches 2. Real-time analysis 3. Huge amount of data (petabytes) 4. High availability data store with no single point of failure Source: http://druid.io/druid.html

## Answer by Kokizzu (score 2)

https://quant.stackexchange.com/a/61958

If you need the column-store for OLAP use cases (not the time series, but this could be done too), try Clickhouse, for 1.1 billion taxi benchmark, it comes 2nd after kx kdb+, and the fastest if eliminating all databases with GPU-based/Xeon-Phi setup.

You may also want to try the newer TiDB that optimized for scaling, it has TiFlash for OLAP use cases

## Answer by databento (score 2)

https://quant.stackexchange.com/a/69448

If you absolutely need a DBMS, the two obvious candidates are Clickhouse and QuestDB, which others have mentioned.

However, there are good chances that you don't need a DBMS. In which case, a plain binary flat file or one with some structure (like HDF5, Parquet) is often the best way to go.

Edit (Dec 16, 2022)

Among flat file options, I now highly recommend the use of Databento Binary Encoding.

- It's written in Rust, with C++ and Python bindings available.

- It's blazing fast thanks to zero copy semantics, binary format and cache line optimization. Benchmarks on a 2020 MacBook Air with the Databento Python client library: Reads are practically I/O-bound at 3.5 GB/s with a single core. Writes are compression-bound at 1.3 GB/s.

- Extremely compact because it primarily uses zstd.

- It's very easy to read into pandas in Python and reserialize it to third party storage formats (pyarrow/parquet, HDF5).

- It's versatile: The protocol supports some instrument metadata and symbology. It's suitable as a message encoding or wire format. We already use it for all our internal normalized market data messages and externally for real-time market data. It's suitable as a on-disk file storage format. We use it internally to store over 3 PB of normalized data, and as the default encoding for all of our customers. Compare this to something like ArcticDB, which has only been used in production at 50+ TB scale.

## Answer by Katie (score 2)

https://quant.stackexchange.com/a/74105

We used Vertica at my last job at a large proprietary trading firm with hundreds of employees.

## Answer by Viktor Sovietov (score 1)

https://quant.stackexchange.com/a/69442

Actually, there is https://theplatform.technology. It does a bit more than kdb, but the internal language is quite close to k with some modern extensions (like pattern matching, etc)

## Answer by Marwin Steiner (score 1)

https://quant.stackexchange.com/a/85438

Speaking from personal experience and having hopped different databases for high-frequency market data for an academic project, ArcticDB has been absolutely painless for me.

Initially, I tried QuestDB and learned that database maintenance is a job unto itself, so I tried ArcticDB, and it has been smooth sailing ever since -- their Python wrapper is easy to use and it's pandas dataframes in and out. You can use it locally with LMDB support for zero-copy reads or wire it to an S3 bucket, though I haven't tried that.

DuckDB exists as well, if you're working from parquet files and just want to use them directly. Have not tried DuckDB myself but heard good things.

Local ArcticDB with billions of rows of data? Works like a charm. Just be careful with slicing and dicing of huge frames. A good database doesn't make memory constraints go away.

## Answer by Will (score 0)

https://quant.stackexchange.com/a/42478

Nowadays many RDBMS do inmemory and columnstore. SQL Server 2017 can do that, and runs very fast

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.