Code Generation
Working with TimeBase, you will often deal with routine tasks such as creation of TimeBase stream schemas based on a specific data model and turning stream schemas into target language objects. Doing it manually may be error-prone and time-consuming. TimeBase offers tools that allow automating such tasks and, thus, saving your time and efforts.
Luminary
Luminary is a IDL language and a library that can be used to describe programing language structures. Java and C# objects can be automatically generated based on Luminary descriptions using custom generators. TimeBase Enterprise Edition includes DOJO and DOCO generators to generate TimeBase-specific messages for Java and C# respectively.
You can use Luminary with TimeBase to perform the following tasks:
- generate TimeBase schemas
- generate TimeBase messages and codecs for C#
- generate TimeBase messages and codecs for Java
Below, you may take a look at an example of a Luminary description and a Java code generated based on it.
- Luminary
- Java
namespace Deltix.Timebase.Api.Messages;
import Deltix.Timebase.Api.*;
/// Basic information about a bar.
[SchemaElement(Name = "deltix.timebase.api.messages.BarMessage", Title = "Bar Message")]
class BarMessage : MarketMessage {
/// Opening price for the bar interval.
//[FieldType(Value = "FLOAT DECIMAL (8)")]
//[Title(Value = "Open")]
[SchemaType(DataType = SchemaDataType.FLOAT, Encoding = "DECIMAL(8)")]
[SchemaElement(Title = "Open")]
[RelativeTo(Value = "close")]
Float64? Open;
/// Highest price for the bar interval.
//[FieldType(Value = "FLOAT DECIMAL (8)")]
//[Title(Value = "High")]
[SchemaType(DataType = SchemaDataType.FLOAT, Encoding = "DECIMAL(8)")]
[SchemaElement(Title = "High")]
[RelativeTo(Value = "close")]
Float64? High;
/// Lowest price for the bar interval.
//[FieldType(Value = "FLOAT DECIMAL (8)")]
//[Title(Value = "Low")]
[SchemaType(DataType = SchemaDataType.FLOAT, Encoding = "DECIMAL(8)")]
[SchemaElement(Title = "Low")]
[RelativeTo(Value = "close")]
Float64? Low;
/// Closing price for the bar interval.
//[FieldType(Value = "FLOAT DECIMAL (8)")]
//[Title(Value = "Close")]
[SchemaType(DataType = SchemaDataType.FLOAT, Encoding = "DECIMAL(8)")]
[SchemaElement(Title = "Close")]
Float64? Close;
/// Trade volume.
//[FieldType(Value = "FLOAT DECIMAL (8)")]
//[Title(Value = "Volume")]
[SchemaType(DataType = SchemaDataType.FLOAT, Encoding = "DECIMAL(8)")]
[SchemaElement(Title = "Volume")]
Float64? Volume;
/// Vendor-specific market code.
//[FieldType(Value = "VARCHAR ALPHANUMERIC(10)")]
//[Title(Value = "Exchange Code")]
[SchemaType(DataType = SchemaDataType.VARCHAR, Encoding = "ALPHANUMERIC(10)")]
[SchemaElement(Title = "Exchange Code")]
[OldElementName("exchangeCode")]
Int64? ExchangeId = TypeConstants.EXCHANGE_NULL;
}
@SchemaElement(name = "deltix.timebase.api.messages.BarMessage", title = "Bar Message")
public class BarMessage extends MarketMessage implements BarMessageInterface {
/**
* Opening price for the bar interval.
*/
protected double open = TypeConstants.IEEE64_NULL;
/**
* Highest price for the bar interval.
*/
protected double high = TypeConstants.IEEE64_NULL;
/**
* Lowest price for the bar interval.
*/
protected double low = TypeConstants.IEEE64_NULL;
/**
* Closing price for the bar interval.
*/
protected double close = TypeConstants.IEEE64_NULL;
/**
* Trade volume.
*/
protected double volume = TypeConstants.IEEE64_NULL;
/**
* Vendor-specific market code.
*/
protected long exchangeId = TypeConstants.EXCHANGE_NULL;
/**
* Opening price for the bar interval.
* @return Open
*/
@SchemaType(encoding = "DECIMAL(8)", dataType = SchemaDataType.FLOAT)
@SchemaElement(title = "Open")
@RelativeTo("close")
public double getOpen() {
return open;
}
/**
* Opening price for the bar interval.
* @param value - Open
*/
public void setOpen(double value) {
this.open = value;
}
/**
* Opening price for the bar interval.
* @return true if Open is not null
*/
public boolean hasOpen() {
return !Double.isNaN(open);
}
/**
* Opening price for the bar interval.
*/
public void nullifyOpen() {
this.open = deltix.timebase.api.TypeConstants.IEEE64_NULL;
}
/**
* Highest price for the bar interval.
* @return High
*/
@SchemaType(
encoding = "DECIMAL(8)",
dataType = SchemaDataType.FLOAT
)
@SchemaElement(
title = "High"
)
@RelativeTo("close")
public double getHigh() {
return high;
}
/**
* Highest price for the bar interval.
* @param value - High
*/
public void setHigh(double value) {
this.high = value;
}
/**
* Highest price for the bar interval.
* @return true if High is not null
*/
public boolean hasHigh() {
return !Double.isNaN(high);
}
/**
* Highest price for the bar interval.
*/
public void nullifyHigh() {
this.high = deltix.timebase.api.TypeConstants.IEEE64_NULL;
}
/**
* Lowest price for the bar interval.
* @return Low
*/
@SchemaType(
encoding = "DECIMAL(8)",
dataType = SchemaDataType.FLOAT
)
@SchemaElement(
title = "Low"
)
@RelativeTo("close")
public double getLow() {
return low;
}
/**
* Lowest price for the bar interval.
* @param value - Low
*/
public void setLow(double value) {
this.low = value;
}
/**
* Lowest price for the bar interval.
* @return true if Low is not null
*/
public boolean hasLow() {
return !Double.isNaN(low);
}
/**
* Lowest price for the bar interval.
*/
public void nullifyLow() {
this.low = deltix.timebase.api.TypeConstants.IEEE64_NULL;
}
/**
* Closing price for the bar interval.
* @return Close
*/
@SchemaType(
encoding = "DECIMAL(8)",
dataType = SchemaDataType.FLOAT
)
@SchemaElement(
title = "Close"
)
public double getClose() {
return close;
}
/**
* Closing price for the bar interval.
* @param value - Close
*/
public void setClose(double value) {
this.close = value;
}
/**
* Closing price for the bar interval.
* @return true if Close is not null
*/
public boolean hasClose() {
return !Double.isNaN(close);
}
/**
* Closing price for the bar interval.
*/
public void nullifyClose() {
this.close = deltix.timebase.api.TypeConstants.IEEE64_NULL;
}
/**
* Trade volume.
* @return Volume
*/
@SchemaType(
encoding = "DECIMAL(8)",
dataType = SchemaDataType.FLOAT
)
@SchemaElement(
title = "Volume"
)
public double getVolume() {
return volume;
}
/**
* Trade volume.
* @param value - Volume
*/
public void setVolume(double value) {
this.volume = value;
}
/**
* Trade volume.
* @return true if Volume is not null
*/
public boolean hasVolume() {
return !Double.isNaN(volume);
}
/**
* Trade volume.
*/
public void nullifyVolume() {
this.volume = deltix.timebase.api.TypeConstants.IEEE64_NULL;
}
/**
* Vendor-specific market code.
* @return Exchange Code
*/
@SchemaType(
encoding = "ALPHANUMERIC(10)",
dataType = SchemaDataType.VARCHAR
)
@SchemaElement(
title = "Exchange Code"
)
@OldElementName("exchangeCode")
public long getExchangeId() {
return exchangeId;
}
/**
* Vendor-specific market code.
* @param value - Exchange Code
*/
public void setExchangeId(long value) {
this.exchangeId = value;
}
/**
* Vendor-specific market code.
* @return true if Exchange Code is not null
*/
public boolean hasExchangeId() {
return exchangeId != deltix.timebase.api.TypeConstants.EXCHANGE_NULL;
}
/**
* Vendor-specific market code.
*/
public void nullifyExchangeId() {
this.exchangeId = deltix.timebase.api.TypeConstants.EXCHANGE_NULL;
}
/**
* Creates new instance of this class.
* @return new instance of this class.
*/
@Override
protected BarMessage createInstance() {
return new BarMessage();
}
}
info
Refer to Luminary open source repository to learn more.
Solution Generator
In case you already have a TimeBase stream schema and you need to create messages in a target language, you can use a tool called Solution Generator to do that.
info
Refer to Solution Generator to learn how to generate classes based on TimeBase schemas.