TickDB Interface Overview

TimeBase offers APIs to view and manage streams, read and write data, run data queries and perform other operations. TimeBase APIs are available for Java, C#, Python, C++, and Go programming languages - please refer to code samples.

TimeBase APIs:

  • TickDB - a top-level API. TickDB API allows connecting to TimeBase, creating and managing streams, and running data queries.
  • TickStream - use TickStream API to get information about streams, manage stream data (delete, truncate, purge and more), create Cursors to read and Loaders to write data into streams.
  • TickCursor - use TickCursor API to read TimeBase stream messages and manage data subscriptions.
  • TickLoader - use TickLoader API to write data into TimeBase streams.

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");

TickDB

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 a specific 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 (stream schema)
// create stream options object
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.

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.

//basic example for your reference
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.