Skip to main content

TickDB API

TickDB - a top-level API. TickDB API allows connecting to TimeBase, creating and managing streams, and running data queries.

info

Refer to code Samples.

Connect to TimeBase Server

Connect to either local or remote TimeBase Server to start working with TimeBase. We have a special dxtick protocol that works on top of TCP to connect to TimeBase server.

Connection to TimeBase server with UAC
  String connectionUrl = "dxtick://localhost:8011";
DXTickDB db = TickDBFactory.createFromUrl(connectionUrl, "username", "password");

Working with Streams

TickDB allows working with TimeBase as with a collection of streams and offers methods to manage them. You can get a stream or a list of streams by a unique stream key identifier:

Get stream
DXTickStream stream = db.getStream("ticks");
Get a list of streams
DXTickStream[] streams = db.listStreams();

Let's now create a stream. To do that, invoke createStream() and pass all the necessary parameters in StreamOptions.

Initialize descriptor and create stream
StreamOptions options = StreamOptions.fixedType(StreamScope.DURABLE, streamName, "My Bar Messages Stream", 0, descriptor);
TickStream stream = db.createStream("BarStreamKey", options);

Each stream has a unique schema (message class definitions), represented by a RecordClassDescriptor (descriptor in the code example) class or a collection of RecordClassDescriptor classes in case of a polymorphic stream. Refer to RecordClassDescriptor to learn how to create and initialize descriptor.

info
  • Refer to Basic Concepts for more information about TimeBase main concepts.
  • Refer to Streams for more information about streams.
  • Refer to Messages for more information about messages.

Data Queries

TickDB allows reading data from multiple streams, according to the specified options, using select(). You can filter data by startTimestamp, types, entities, and streams. It is possible to change data filters on the fly. Refer to Dynamic Subscription Change to learn more.

try (TickCursor cursor = db.select(startTimestamp, selectionOptions, types, entities, streams)) {
// iterate cursor
}

TickDB also allows running QQL queries using executeQuery() method.

Simple select command example
try (InstrumentMessageSource cursor = db.executeQuery("select * from bars")) {
// iterate cursor
}

Both methods have a vast variety of overloaded versions with different parameters such as time, identities, message types filters and more.

info
  • Refer to QQL Tutorial for more information about the TimeBase query language.
  • Refer to Cursors for more information about cursor and InstrumentMessageSource.