Contents
The StreamBase InfoReach TMS adapter gives a StreamBase application access to the InfoReach TMS trade management system. The adapter runs embedded within the StreamBase application itself.
The InfoReach TMS adapter is bidirectional. It is primarily a StreamBase input adapter, accepting input from the TMS system, and its icon in EventFlow diagrams is the same as other input adapters. But the adapter also provides output features, although it is not designed to be used strictly as an output adapter.
The adapter registers for TMS events and emits a tuple for each event. There are four output ports in all, each one dedicated to a specific event type (market porfolios, market targets, market orders and actions.) The exact schema of each port can be tailored to include only the relevant TMS fields for a given type of event.
An input port is also provided to allow the StreamBase application to issue commands to the TMS system, such as sending or canceling market orders.
The adapter is configured through a collection of properties, typically set in the
adapter's Properties view within StreamBase Studio. Properties specify,
among other things, the location of the TMS installation on the machine, the name of
the configuration XML file for the output port schemas, and the list of event types
to subscribe to. For an example of this configuration file, see the tmsadapterconfig.xml file in the included TMS adapter sample.
Note
This adapter is not provided in the base StreamBase kit, but is available in a separate installation kit. Please contact StreamBase Systems if you are interested in the kit.
| Property | Description |
|---|---|
| TMS Installation Directory | The location on disk of the InfoReach TMS system. |
| Configuration File | The name of the XML resource file containing the description of the schema for the various ports of the adapter. |
| Maximum Length Of String Fields | The default maximum number of characters to assign to string fields. This is necessary because StreamBase field strings are of fixed length, while TMS field strings are of arbitrary length. When assigning a TMS field's string value to a StreamBase string field, the string is truncated as needed to fit the maximum length indicated by this property. For a given TMS field, you can also override the default maximum length by editing the XML configuration file entry for that field. By default, the specified length for string fields is -1 in the configuration file, which specifes that the default value should be used. Setting the length attribute to any other value overrides the default and uses that value instead. |
| Subscribe To Target Events | If checked, this property causes the adapter to subscribe to market target events. An additional output port is made available on the adapter to access these events. |
| Subscribe To Order Events | If checked, this property causes the adapter to subscribe to market order events. An additional output port is made available on the adapter to access these events. |
This section demonstrates how to use the InfoReach TMS adapter within a StreamBase application. The figure below shows the adapter's sample application, where the adapter uses one input port and at most four output ports to communicate with the surrounding application.
Note
In the sample application, the adapter's input and output ports are directly connected to externally-visible input and output streams. However, in more complex applications, these ports are typically connected to internal StreamBase operators.
The InfoReach TMS adapter's ports are used as follows:
-
Input: Commands. Tuples enqueued on the Commands port cause the adapter to send specific commands to the TMS system, such as to place an order. The schema of the Commands port is derived from the upstream operator or stream and is expected to have a strict subset of the following fields:
-
InstructionType, string (size 32): specifies the type of instruction to be carried out. Its value should be one of the following:
-
SendOrder — Executes an order for the target identified by the TargetId field (see below).
-
CancelOrders — Cancels all open orders for the given TargetId.
-
-
ActionId, long: specifies a value, supplied by the StreamBase application, to uniquely identify this command. This value is passed back to the application when Action Events (Finished, Error, and so on) are generated for this command. See the Actions schema below for details.
-
TargetId, long: specifies the target to which to apply the command.
-
All other fields in this schema are expected to be a subset of those contained in the TMSNewOrderMessage class in the TMS Java API. Those fields are listed in the
tmsadapterconfig.xmlsample configuration file in the section <Schemas><InputSchemas><Schema name="Instructions">.
-
-
Output: Actions. After commands are issued, the results are returned by the TMS system as Action events. See the
com.inforeach.util.action.IActionEventListenerinterface in the TMS Java API. Each action event corresponds to a specific command, identified by the ActionId field (see the ActionId field in the Commands input schema.)The fields of the Actions schema are as follows:
-
ActionEventType, string (size 32): specifies the type of action event. Valid values are:
-
Alert
-
Error
-
Finished
-
Event
-
Progress
-
-
ActionId, long: identifies the command for which this action event was issued. This value is passed back unchanged from that given in the ActionId field of the Commands input stream tuple that issued the command.
-
ActionDescription, string(default maximum length): Describes the action.
-
Message, string(default maximum length): Message conveyed by the action. For example, in the case of an Error action event, this field contains the text of the error message.
-
CurrentStep, int: Used in conjunction with the TotalSteps field to determine progress in the case of a Progress action event.
-
TotalSteps, int: Used in conjunction with the CurrentStep field to determine progress in the case of a Progress action event.
-
-
Output: Portfolios. This output port emits tuples in response to portfolio-related events. See the
com.inforeach.eltrader.tms.domain.portfolio.api.ITMSMarketPortfolioEventRemoteListenerinterface in the TMS Java API.The Portfolios port has the following schema:
-
PortfolioEventType, string (size 32): specifies the type of portfolio event. Valid values are:
-
Added
-
Updated
-
InitialStateReceived
-
FilteredOut
-
Disconnected
-
Reconnected
-
Error
-
Removed
-
-
PortfolioName, string(default maximum length): the name of this portfolio.
-
ErrorMessage, string(default maximum length): in case of an Error event, contains the text of the error message.
-
The rest of the fields are expected to be a subset of those contained in the
com.inforeach.util.IRecordclass in the TMS Java API. To add or remove fields from the schema, edit thetmsadapterconfig.xmlfile's section located at <Schemas><OutputSchemas><Schema name="PortfolioEvents">.
-
-
Output: Targets. This output port emits tuples in response to a portfolio's target-related events. See the
com.inforeach.eltrader.tms.api.ITMSMarketTargetEventRemoteListenerinterface in the TMS Java API.The Targets port has the following schema:
-
TargetEventType, string (size 32): specifies the type of target event. Valid values are:
-
Added
-
Updated
-
InitialStateReceived
-
FilteredOut
-
Disconnected
-
Reconnected
-
Error
-
Removed
-
Paused
-
Resumed
-
Terminated
-
-
TargetId, long: uniquely identifies this target within its portfolio.
-
ErrorMessage, string(default maximum length): in case of an Error event, contains the text of the error message.
-
The rest of the fields are expected to be a subset of those contained in the
com.inforeach.util.IRecordclass in the TMS Java API. To add or remove fields from the schema, edit thetmsadapterconfig.xmlfile's section located at <Schemas><OutputSchemas><Schema name="TargetEvents">.
-
-
Output: Orders. This output port emits tuples in response to a portfolio's order-related events. See the
com.inforeach.eltrader.tms.api.ITMSOrderEventRemoteListenerinterface in the TMS Java API.The Orders port has the following schema:
-
OrderEventType, string (size 32): specifies the type of order event. Valid values are:
-
Added
-
Updated
-
InitialStateReceived
-
FilteredOut
-
Disconnected
-
Reconnected
-
Error
-
-
OrderEventId, long: uniquely identifies this order within its portfolio.
-
ErrorMessage, string(default maximum length): in case of an Error event, contains the text of the error message.
-
The rest of the fields are expected to be a subset of those contained in the
com.inforeach.util.IRecordclass in the TMS Java API. To add or remove fields from the schema, edit thetmsadapterconfig.xmlfile's section located at <Schemas><OutputSchemas><Schema name="OrderEvents">.
-
To add an instance of the adapter to a new StreamBase application:
-
Within StreamBase Studio, create a project, including a StreamBase EventFlow to host the adapter.
-
Import into the project the XML configuration file,
tmsadapterconfig.xml, which is located in.streambase-install-dir/sample/adapter/embedded/inforeach-tms -
Drag an instance of the TMS adapter from the Global Adapter drawer in the Palette view to the EventFlow canvas.
-
Connect an Input stream to the input port of the adapter. Configure the schema of the input stream as defined in the description of the Commands port above.
-
Set the required properties of the TMS adapter by double-clicking the adapter in the diagram. In the StreamBase Properties view, select the Adapter Settings tab. You must specify the directory where TMS is installed on your machine. Select the
tmsadapterconfig.xmlfile in the Configuration File drop-down list. At this point you can optionally change the default length of string fields, and change whether to subscribe to target and order events, (which will adjust the number of output ports of the adapter correspondingly). -
Connect Output streams to the adapter's output ports. Depending on your selections above, you may have two, three, or four output ports to connect.
The InfoReach TMS adapter uses typecheck messages to help you configure the adapter within your StreamBase application. In particular, the adapter generates typecheck messages if the TMS Installation Directory or Configuration File are missing or invalid or when one or more required fields in the input schema is missing or is of the wrong type.
On suspend, the InfoReach TMS adapter unsubscribes for all event notifications from the InfoReach TMS system.
When it resumes, the adapter re-subscribes to the event streams.
