MarketFactory™ Trading Adapter

This adapter is part of the TIBCO StreamBase CEP Connectivity Package.

Introduction

The TIBCO StreamBase® Adapter for MarketFactory Whisperer™ Trading allows a StreamBase application to place orders and receive trading-related events from a MarketFactory Trading server. The MarketFactory Trading adapter is a single, bidirectional adapter that can both send and receive MarketFactory messages. To facilitate its use in EventFlow diagrams, the adapter is represented as an Input adapter and an Output adapter, with separate icons in the StreamBase Studio Palette view. These icons must be used as a pair that shares a single MarketFactory connection (described below in Linking Input and Output adapters).

The adapter has the following capabilities:

  • Establishes a connection to the MarketFactory Trading server.

  • Subscribes to specific markets and obtains trading events from these markets, as well as places trades with those subscribed markets.

  • Converts the incoming trading events from the MarketFactory server and sends them as tuples to the StreamBase application.

  • Converts incoming tuples from the StreamBase application into trading events that are then sent to the MarketFactory server.

  • Optionally receives commands from the StreamBase application to log on to, or log out from, the MarketFactory server.

The Input side of the adapter exposes a set of output ports, and the Output side exposes a set of input ports, the fields for which are defined later in this document. In addition, each side of the adapter exposes a set of adapter properties as described in the next section.

Linking Input and Output adapters

Having separate Input and Output adapter icons for EventFlow applications minimizes the need for loops in EventFlow logic. The Input and Output adapters share a connection to the MarketFactory Trading server.

To link MarketFactory Trading Input and Output adapters so that they share a single MarketFactory connection, follow these steps:

  • Create a MarketFactory Trading Input adapter and configure it to connect to the MarketFactory server, as described in Adapter Properties Tab. In this Input adapter's General tab, note the value of the Name parameter. For clarity, specify a non-default name For this example, we will use the name MyMFTradingInputAdapter.

  • Create an instance of the MarketFactory Trading Output adapter.

  • In this new adapter's Adapter Properties tab, fill in the Share A Connection With The MarketFactory Trading Input Adapter Named field, enter the name of your Input adapter (MyMFTradingInputAdapter in our example).

    Note

    Make sure the spelling matches the Input adapter's name exactly or a runtime error occurs indicating that the specified Input adapter is not found.

Properties

Settings are used to control most of the behavior of the adapter. The settings are grouped under several tabs in the Properties view in StreamBase Studio.

In the table in this section, the Property column shows each property name as found in the one or more adapter properties tabs of the Properties view for this adapter.

When using this adapter in a StreamSQL program with the APPLY JAVA statement, you must convert the Studio property names to parameter names using the simple formula described in APPLY Statement. For cases where the Studio property name is not convertible in an obvious way, the StreamSQL parameter name is included in the Description column.

Input Adapter Properties

General Tab

Name: Use this field to specify or change the component's name, which must be unique in the application. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.

Adapter: A read-only field that shows the formal name of the adapter.

Class: A field that shows the fully qualified class name that implements the functionality of this adapter. Use this class name when loading the adapter in StreamSQL programs with the APPLY JAVA statement. You can right-click this field and select Copy from the context menu to place the full class name in the system clipboard.

Start with application: If this field is set to Yes or to a module parameter that evaluates to true, an instance of this adapter starts as part of the containing StreamBase Server. If this field is set to No or to a module parameter that evaluates to false, the adapter is loaded with the server, but does not start until you send an sbadmin resume command, or until you start the component with StreamBase Manager. With this option set to No or false, the adapter does not start even if the application as a whole is suspended and later resumed. The recommended setting is selected by default.

Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports and Error Streams to learn about Error Ports.

Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.

Adapter Properties Tab

Property Data Type Default Description
Configuration File drop-down list none The name of the MarketFactory configuration to use to connect to the MarketFactory server. Refer to your particular MarketFactory product installation to determine the file to use.

This control is a drop-down list that shows the available files in the current Studio project. Import the MarketFactory configuration into your Studio project so that it can be selected in the list.

(StreamSQL property name: configFile)

Use Automatic Failover check box false (cleared) When selected, the adapter does not try to connect to the host and port specified in the Host Name and Port Number properties, but rather looks in the MarketFactory configuration file for a list of hosts and ports to which to connect. If a connection cannot be established (or is subsequently lost), the next host in the list will be contacted instead, thus implementing a form of failover strategy.

(StreamSQL property name: useAutomaticFailover)

Host Name string none The name or IP address of the MarketFactory Enhanced Market Data server to which to connect.

Only enabled if Use Automatic Failover is cleared.

(StreamSQL property name: hostName)

Port int none The port to which to connect on the MarketFactory server.

Only enabled if Use Automatic Failover is cleared.

(StreamSQL property name: hostPort)

User Name string none The username to use when signing on to the trading server.

(StreamSQL property name: userName)

Password string none The password to use when signing on to the trading server.

(StreamSQL property name: password)

Connect On Startup check box true (selected) When selected, the adapter attempts to connect to the MarketFactory server immediately after starting. If cleared, the adapter remains idle after starting and waits for a Connect command as described in Command Input Port.

(StreamSQL property name: connectOnStartup)

Reconnect Retries int 0 The number of times the adapter is to attempt reconnection if the first connection attempt is unsuccessful.

(StreamSQL property name: reconnectRetries)

Reconnect Interval (in seconds) int 10 Specifies the number of seconds to wait between reconnection attempts. This value is ignored unless Reconnect Retries has a non-zero positive value.

(StreamSQL property name: reconnectInterval)

Logging Tab

Property Data Type Default Description
Log Level drop-down list INFO Controls the level of verbosity the adapter uses to send notifications to the console. This setting can be higher than the containing application's log level. If set lower, the system log level will be used. Available values, in increasing order of verbosity, are: OFF, ERROR, WARN, INFO, DEBUG, TRACE, and ALL.
Report Profiling Data check box false (cleared) When selected, the adapter collects data on how long it takes to process incoming messages, and regularly reports the results to the console. Reported data includes the average, standard deviation, minimum and maximum times (in microseconds) taken to receive each market data message, convert it into a tuple and send it to the application. This is useful when troubleshooting performance issues in your application.

(StreamSQL property name: isReportingProfilingData)

Reporting Interval (in # of messages) int 10000 When Report Profiling Data is checked, this property specifies the number of incoming messages after which performance data is reported to the console. A positive integer is expected. This property is ignored if Report Profiling Data is cleared.

(StreamSQL property name: profilingDataReportingInterval)

Concurrency Tab

Use the Concurrency tab to specify parallel regions for this instance of this component, or multiplicity options, or both. The Concurrency tab settings are described in Concurrency Options, and dispatch styles are described in Dispatch Styles.

Caution

Concurrency settings are not suitable for every application, and using these settings requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.

Output Adapter Properties

General Tab

Name: Use this field to specify or change the component's name, which must be unique in the application. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.

Adapter: A read-only field that shows the formal name of the adapter.

Class: A field that shows the fully qualified class name that implements the functionality of this adapter. Use this class name when loading the adapter in StreamSQL programs with the APPLY JAVA statement. You can right-click this field and select Copy from the context menu to place the full class name in the system clipboard.

Start with application: If this field is set to Yes or to a module parameter that evaluates to true, an instance of this adapter starts as part of the containing StreamBase Server. If this field is set to No or to a module parameter that evaluates to false, the adapter is loaded with the server, but does not start until you send an sbadmin resume command, or until you start the component with StreamBase Manager. With this option set to No or false, the adapter does not start even if the application as a whole is suspended and later resumed. The recommended setting is selected by default.

Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports and Error Streams to learn about Error Ports.

Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.

Adapter Properties Tab

Property Data Type Default Description
Share A Connection With The MarketFactory Trading Input Adapter Named string none The name of the MarketFactory Trading Input adapter with which to share a connection.

(StreamSQL property name: inputAdapterName)

Logging Tab

This tab is identical to the one exposed by the Input adapter. See Logging Tab.

Concurrency Tab

Use the Concurrency tab to specify parallel regions for this instance of this component, or multiplicity options, or both. The Concurrency tab settings are described in Concurrency Options, and dispatch styles are described in Dispatch Styles.

Caution

Concurrency settings are not suitable for every application, and using these settings requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.

Adapter Ports And Schemas

Input Adapter Ports

Output Ports

The MarketFactory Trading Input adapter has five output ports:

  • The first port routes the Symbol Map messages received on connection to the MarketFactory server.

  • The second port routes incoming Feed Subscription Response Event messages from the server.

  • The third port routes incoming Trading Events from the MarketFactory server.

  • The fourth port routes incoming Event Reports from the MarketFactory server.

  • The fifth port routes interesting events, such as connection and disconnection from the server, error conditions, and so on.

The schema for each output port is described in the following subsections.

Symbol Map Output Port Schema

The first output port routes incoming Symbol Map messages to the StreamBase application. Typically, one such message will be sent by the server upon connection, to describe the available feeds, styles and currency pairs.

The schema for this port is pre-set by the adapter, and is described in the following table:

Field Name Field Type Description
styles list<tuple> Contains a list of styles available on this server.
  id int Id of this style.
name string Name of this style.
feeds list<tuple> Contains a list of feeds available on this server.
  id int Id of this feed.
name string Name of this feed.
currencyPairs list<tuple> Contains a list of currency pairs available on this server.
  id int Id of this currency pair.
name string Name of this currency pair.
Feed Subscription Response Event Output Port Schema

The second output port routes incoming Feed Subscribe Response Event messages to the StreamBase application.

The schema for this port is pre-set by the adapter, and is described in the following table:

Field Name Field Type
actionId long
traderId long
text string
subscriptionRejected bool
rejectReason string
feedMarketList list<tuple>
^ feedName string
currencyPair string
Trading Events Output Port Schema

The third output port routes incoming Trading Event messages to the StreamBase application. These message use a complex structure, and the validity and meaning of each field may vary depending on the feed and style requested when the currency pair was subscribed to. Because of this, this document does not attempt to describe each field's semantics in detail and defers to the MarketFactory Trading product's own documentation instead. Specifically, the documents entitled MarketFactory Java API Programming Guide, Revision 1.3 and MarketFactory Style Specification, Revision 1.0 should be consulted.

The schema for this port is pre-set by the adapter, and is described in the following table:

Field Name Field Type Description
signal string  
eventEntries list<tuple> Contains a list of all the TradingEventEntry objects contained in the incoming message.
^ tradingEventName string The type of event represented here. May be one of the following values:
  • ORDERCANCELEXEC

  • ORDERCANCELREJECT

  • ORDERDONEEXEC

  • ORDERSUBMITEXEC

  • TRADECAPTURE

^ tradingEvent tuple The actual event data. Different types of events may use different fields in the schema of this nested tuple.
^ ^ clientOrderId string  
^ ^ counterpartyId string  
^ ^ customerId int  
^ ^ exchangeId int  
^ ^ exchangeOrderId string  
^ ^ execId string  
^ ^ feedName string  
^ ^ isTaker bool  
^ ^ currencyPair string  
^ ^ matchStatus string One of:
  • CONFIRMED

  • DONE

  • PENDING

  • UNKNOWN

  • UNVERIFIED

  • INVALID

^ ^ orderId long  
^ ^ orderSide string One of:
  • BID

  • BUY

  • BUY_BID

  • OFFER

  • SELL

  • SELL_OFFER

  • INVALID

^ ^ orderStatus string One of:
  • ACCEPTEDFORBIDDING

  • CALCULATED

  • CANCELED

  • DONEFORDAY

  • EXPIRED

  • FILLED

  • NEW

  • PARTIALLYFILLED

  • PENDINGCANCEL

  • PENDINGNEW

  • REJECTED

  • REPLACED

  • STOPPED

  • SUSPENDED

  • INVALID

^ ^ reportingDealId long  
^ ^ tradeAmount tuple  
^ ^ ^ amount double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN bool  
^ ^ isNoDataAvailable bool  
^ ^ isNoMarketActivity bool  
^ ^ isNotApplicable bool  
^ ^ tradeDate int  
^ ^ tradeId string  
^ ^ tradePrice tuple  
^ ^ ^ price double  
^ ^ specialValue string Contain the string representation of the special value, or is null if this price does not represent a special value.
^ ^ isNAN bool  
^ ^ isNoDataAvailable bool  
^ ^ isNoMarketActivity bool  
^ ^ isNotApplicable bool  
^ ^ transactTime long This timestamp is expressed in nanoseconds since 1970/01/01 00:00:00 UTC (the Java epoch). It cannot be expressed by a StreamBase timestamp without losing precision, so it is left as a long.

If you wish to convert this value to a StreamBase timestamp, do so by dividing the value by 1000000 (one million) before assigning it to the timestamp.

^ ^ userId string  
^ ^ cumulativeAmount tuple  
^ ^ ^ amount double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN bool  
^ ^ isNoDataAvailable bool  
^ ^ isNoMarketActivity bool  
^ ^ isNotApplicable bool  
^ ^ leavesAmount tuple  
^ ^ ^ amount double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN bool  
^ ^ isNoDataAvailable bool  
^ ^ isNoMarketActivity bool  
^ ^ isNotApplicable bool  
^ ^ cancelAmount tuple  
^ ^ ^ amount double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN bool  
^ ^ isNoDataAvailable bool  
^ ^ isNoMarketActivity bool  
^ ^ isNotApplicable bool  
^ ^ cancelId string  
^ ^ cancelRejectReason string One of:
  • BROKEREXCHANGEOPTION

  • CLORDIDNOTRECOGNIZED

  • INVALIDPRICEINCREMENT

  • ORDERALREADYPENDINGCANCELORREPLACE

  • OTHER

  • TOOLATETOCANCEL

  • UNABLETOPROCESSORDERMASSCANCELREQUEST

  • UNKNOWNORDER

  • INVALID

^ ^ cancelRejectResponseTo string One of:
  • ORDERCANCELREPLACEREQUEST

  • ORDERCANCELREQUEST

  • INVALID

^ ^ orderAmount tuple  
^ ^ ^ amount double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN bool  
^ ^ isNoDataAvailable bool  
^ ^ isNoMarketActivity bool  
^ ^ isNotApplicable bool  
^ ^ orderRejectReason string  
^ ^ text string Textual description of the trading event, if available.
Event Report Output Port Schema

The fourth output port routes incoming Event Report messages to the StreamBase application.

The schema for this port is pre-set by the adapter, and is described in the following table:

Field Name Field Type Description
seqNumber long  
batchId long  
eventReportEntries list<tuple> Contains the list of Event Reports contained in this message.
^ feedId int  
marketId int  
eventType string One of:
  • TRADEDATEROLLOVER

  • TRADINGDAYROLLOVER

  • VALUEDATEROLLOVER

  • INVALID

eventContents string  
Events Output Port Schema

The fifth output port routes incoming events from the MarketFactory server to the StreamBase application. These events may connection and disconnection from the server, subscription failures and so forth.

The schema for this port is pre-set by the adapter, and is described in the following table:

Field Name Field Type Description
eventType string The type of event represented by this tuple. Possible values are:
  • Connected: The adapter has connected to the MarketFactory server.

  • Disonnected: The adapter has disconnected from the MarketFactory server.

  • Connection Lost: The adapter has lost its connection to the MarketFactory server.

  • Connection Failed: The adapter has failed to connect to the MarketFactory server.

  • Subscription Failed: The adapter has failed to subscribe to the requested currency pair.

  • Unsubscription Failed: The adapter has failed to unsubscribe from the requested currency pair.

  • Signon Ack: An event of type Signon Ack was received from the MarketFactory server.

  • Signoff Ack: An event of type Signoff Ack was received from the MarketFactory server.

This field is guaranteed to be non-null for all events.

info string Contains explanatory text for the event.

This field is guaranteed to be non-null for all events.

code string If relevant, will contain an error code.

This field may be null for some events.

userId string

Only used for Signoff Ack events.

This field may be null for some events.

rejectReason string Only used for Signon Ack and Signoff Ack events.

This field may be null for some events.

status string Only used for Signon Ack and Signoff Ack events.

This field may be null for some events.

customerId int

Only used for Signon Ack events.

This field may be null for some events.

nodeId int

Only used for Signon Ack events.

This field may be null for some events.

sessionId int

Only used for Signon Ack events.

This field may be null for some events.

Output Adapter Ports

Input Ports

The adapter has two input ports. The first port allows applications to send commands to the adapter. The second port allows applications to place orders (trades) with the MarketFactory server.

Command Input Port

The schema for the Command Input port is expected to contain the following fields:

Field Name Field Type Field Description
command string Contains the name of the command to execute. This field is required to be non-null for all supported commands. See below for a list of the available commands.
feedName string This field may be left null for some types of commands. See description below.
currencyPair string This field may be left null for some types of commands. See description below.
actionId long Unique identifier which will be associated with this request. This field may be left null for some types of commands.
traderReqId long Unique identifier associated with the subscription being managed by this request. This field may be left null for some types of commands.

Available commands include:

  • Connect: Log on to the configured MarketFactory Enhanced Market Data server. Required fields:

    • command: Should contain the value Connect. Case is unimportant.

  • Disconnect: Log out of the MarketFactory Enhanced Market Data server. Required fields:

    • command: Should contain the value Disconnect. Case is unimportant.

  • Subscribe: Subscribe to a currency pair from a specific feed using a specific style. Required fields:

    • command: Should contain the value Subscribe. Case is unimportant.

    • currencyPair: The currency pair to which a subscription is desired.

    • feedId: The feed ID of the feed on which the subscription is desired.

    • actionId: An arbitrary unique identifier associated with the subscription being managed by this request. It shall be generated by the customer application and is referred to in the following subsequent subscription reject or trading messages.

    • traderReqId: An arbitrary unique identifier associated with this request which shall be passed as a reference in a subsequent trading feed request reject message.

  • Unsubscribe: Unsubscribe from a currency pair from a specific feed using a specific style. Required fields:

    • command: Should contain the value Unsubscribe. Case is unimportant.

    • currencyPair: The currency pair to which a subscription is desired.

    • feedId: The feed ID of the feed on which the subscription is desired.

    • actionId: An arbitrary unique identifier associated with the subscription being managed by this request. It shall be generated by the customer application and is referred to in the following subsequent subscription reject or trading messages.

    • traderReqId: An arbitrary unique identifier associated with this request which shall be passed as a reference in a subsequent trading feed request reject message.

Trading Input Port

The schema for the Trading Input port is expected to contain the following fields:

Field Name Field Type Description
signalId int  
orderSubmitEntries list<tuple> Use this to place orders. You can batch orders by including multiple entries in the list.
^ clientOrderId string  
^ dealCode string  
^ expireDate bool  
^ expireTime timestamp  
^ feedName string  
^ currencyPair string  
^ maxShow tuple  
^ ^ amount double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN bool  
^ ^ isNoDataAvailable bool  
^ ^ isNoMarketActivity bool  
^ ^ isNotApplicable bool  
^ onLocalCurrency bool  
^ orderAmount tuple  
^ ^ amount double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN bool  
^ ^ isNoDataAvailable bool  
^ ^ isNoMarketActivity bool  
^ ^ isNotApplicable bool  
^ orderPrice tuple  
^ ^ price double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN string  
^ ^ isNoDataAvailable string  
^ ^ isNoMarketActivity string  
^ ^ isNotApplicable string  
^ orderSide string One of:
  • BID

  • BUY

  • BUY_BID

  • OFFER

  • SELL

  • SELL_OFFER

  • INVALID

^ orderType string One of:
  • FOREXLIMIT

  • FOREXMARKET

  • FOREXPREVIOUSLYQUOTED

  • FOREXSWAP

  • FUNARI

  • IFDOCOORDER

  • IFDORDER

  • LIMIT

  • LIMITONCLOSE

  • LIMITORBETTER

  • LIMITWITHORWITHOUT

  • LINKEDAMOUNTORDER

  • MARKET

  • MARKETONCLOSE

  • OCOORDER

  • ONBASIS

  • ONCLOSE

  • PEGGED

  • PREVIOUSLYINDICATED

  • STOP

  • STOPLIMIT

  • WITHORWITHOUT

  • INVALID

^ stopPrice tuple  
^ ^ price double  
^ ^ specialValue string Contains the string representation of the special value, or is null if this amount does not represent a special value.
^ ^ isNAN string  
^ ^ isNoDataAvailable string  
^ ^ isNoMarketActivity string  
^ ^ isNotApplicable string  
^ timeInForce string One of:
  • ATTHEOPENING

  • DAY

  • FILLORKILL

  • FOK

  • GOODTILLCANCEL

  • GOODTILLCROSSING

  • GOODTILLDATE

  • GTD

  • GTC

  • GTX

  • IMMEDIATEORCANCEL

  • IOC

  • OPG

  • INVALID

^ traderId string  
orderCancelEntries list<tuple> Use this to cancel orders. You can batch cancel operations by including multiple entries in the list.
^ cancelId string  
^ clientOrderId string  
^ currencyPair string  
^ orderId long  
^ orderSide string One of:
  • BID

  • BUY

  • BUY_BID

  • OFFER

  • SELL

  • SELL_OFFER

  • INVALID

^ orderType string One of:
  • FOREXLIMIT

  • FOREXMARKET

  • FOREXPREVIOUSLYQUOTED

  • FOREXSWAP

  • FUNARI

  • IFDOCOORDER

  • IFDORDER

  • LIMIT

  • LIMITONCLOSE

  • LIMITORBETTER

  • LIMITWITHORWITHOUT

  • LINKEDAMOUNTORDER

  • MARKET

  • MARKETONCLOSE

  • OCOORDER

  • ONBASIS

  • ONCLOSE

  • PEGGED

  • PREVIOUSLYINDICATED

  • STOP

  • STOPLIMIT

  • WITHORWITHOUT

  • INVALID

^ timeInForce string One of:
  • ATTHEOPENING

  • DAY

  • FILLORKILL

  • FOK

  • GOODTILLCANCEL

  • GOODTILLCROSSING

  • GOODTILLDATE

  • GTD

  • GTC

  • GTX

  • IMMEDIATEORCANCEL

  • IOC

  • OPG

  • INVALID

orderCancelAllEntries list<tuple> Use this to cancel all orders. You can batch cancels by including multiple entries in the list.
^ cancelId string  

Typechecking and Error Handling

The adapter uses typecheck messages to help you configure the adapter in your StreamBase application. In particular, the adapter generates typecheck messages for the following reasons:

  • A required property is missing.

  • One or more required fields in the Command input port is missing or is of the wrong type or size.

Suspend/Resume Behavior

When suspended, the adapter remains connected to the MarketFactory server if it was already connected, but all incoming messages and events from the server are dropped.

When resumed, the adapter starts routing incoming messages and events from the server to the StreamBase application again.

Related Topics