TickLoader API
Writing Messages
Use TickLoader API to create loaders to write into TimeBase streams.
- Pass
loadingOptions()and callcreateLoader(). Refer to javadoc to learn more about loading options. - Use
loader.send()method to send your messages to the loader. - Call
loader.close()function once writing is completed.
- Java
- Python
LoadingOptions options = new LoadingOptions();
try (TickLoader<InstrumentMessage> loader = changeStream.createLoader(options)) {
loader.send(message);
}
# Create BestBidOffer message
barMessage = dxapi.InstrumentMessage()
# Define message type name according to the Timebase schema type name
barMessage.typeName = 'deltix.timebase.api.messages.BarMessage'
barMessage.instrumentType = 'EQUITY'
barMessage.symbol = 'AAPL'
barMessage.open = 10.0
barMessage.close = 20.0
#...
with stream.tryLoader(dxapi.LoadingOptions()) as loader:
loader.send(barMessage)
Refer to code samples to view more examples.
Writing Raw Data
Loaders can write messages already bound to native classes or raw messages (unbound).
options.raw = true;
Refer to Data Encoding for more information about encoding and decoding messages.
Writing Modes
TimeBase can be seen as chronologically arranged pieces of data. In relation to that, TimeBase offers several different data writing modes that can be set in LoadingOptions.writeMode when creating a new loader:
Stream truncation - operation that removes all messages with timestamps that are either equal or newer than the timestamp of the incoming message.
- REWRITE
- APPEND
- TRUNCATE
- INSERT
Default writing mode.
When you start writing, the stream is always truncated by the timestamp of the first incoming message (which may have an out of sequence timestamp).
To write all the following messages into a stream, they must go in a chronological order (e.g. T1, T2. T3 ...).
In this writing mode only messages with timestamps that are not older than the last recorded message timestamp are written into a stream. Messages must go in a chronological order (e.g. T1, T2. T3 ...) to be written into a stream.
In this writing mode, a stream is always truncated with the first message.
With all the following messages, stream is truncated if the incoming message has a timestamp that is older than the last recorded message.
In this writing mode, new messages are written into a stream without truncation.
Refer to Data Distribution.
- Java
- Python
//truncate
options.writeMode = WriteMode.TRUNCATE;
#truncate
options = dxapi.LoadingOptions()
options.writeMode = dxapi.WriteMode('TRUNCATE')