This document describes the WEB Socket API used for the Trading Engine a.k.a TE
The WEB Socket interface is used for disseminating i.e unsolicited data updates (i.e. broadcasts) from the TE to clients. The reader of this document should be familiar with the Trading Engine REST API.
The data format used when publishing data from the Trading engine is JSON.
In order to receive data the client application must connect to the TE WEB Socket endpoint.
The endpoint is always using an encrypted schema i.e. HTTPS.
When connecting to the endpoint a query “ApiAuthId” parameter must be provided e.g.
WSS endpoint : "wss://<host>:<port>/marketdata?authid=<te-api-authid>"
The APIAuthId parameter is returned in the logon response after a successful logon to the TE. For details see the logon request in the TE REST API.
Market data is not sent to a client unless the client has subscribed to it. So after a successful connection to the TE WEB Socket service the client should request subscription to the data the client is interested in.
This is done by sending a subscription request message to the TE WEB Socket service.
All data published is associated with a topic name being a hierarchical structure, represented as a string having the forming format “/<bdx-flow>/<Markket>/<symbol>” i.e three levels.
Each level seprated by a slash i.e. “/”. e.g. “/BdxBBO/1/AMZN” for a best bid/offer update for the stock Amazon.
The subscription request message has the following JSON format
{ "command" : string, "topic" : string }
Topics can contain wildcards. The strings “*” and “…” are used to express wildcard matching.
The market data service will always publish data with absolute topic names i.e. must not contain the strings “*” or “…”.
Subscribers may use absolute topics or wildcard subject when setting up subscriptions.
Subject names are case sensitive.
Some typical matching rules.
“/foo/bar” will not match “/foo/bar/fie”
“/foo/*” will match all topics with two levels and starting with “/foo”
“/foo/*/bar/*” will match all subjects with four levels, where level one is equal with “/foo” level three
with “/bar” and level two and four being whatever.
“/foo/bar/…” will match anything with three or more levels, starting with “/foo” and “/bar” at level one and two.
“/…” will match everything being published.
Currently the TE can be configured to publishing the following messages flows.
Description: Published to the owner (account) of the order when the order is changed in an orderbook.
{ BdxOwnOrderbookChange : {
"sid" : string
"orderId" : string
"action" : string (ADD,REMOVE,MODIFY)
"price" : long
"quantity" : integer
"side" : string (BUY, SELL)
"ref" : string
"obSeqNo" : long
}
}
Description: published to all clients connected to the wss market data service when and order has been changed.
{ BdxOrderbookChange: {
"sid" : string
"orderId" : string
"action" : string (ADD,REMOVE,MODIFY)
"price" : long
"quantity" : integer
"side" : string (BUY, SELL)
"obSeqNo" : long
}
}
Description: published to the account owner when any of its orders have been matched.
{ BdxOwnTrade: {
"sid" : string,
"orderId" : string,
"price" : long,
"quantity" : integer,
"side" : string (BUY, SELL),
"time" : string,
"tradeId" : string,
}
Description: published to all clients connected to the wss market data service when there is match between two orders occurs.
{ BdxTrade: {
"sid" : string,
"last" : string,
"quantity" : integer,
"open" : string,
"low" : long,
"high" : long,
"time" : string,
"totalQuantity" : integer
}
Description: BdxPriceLevel is a broadcast containing an aggregated view of the ‘n’ best price levels. Normally configured to expose 5 levels. The broadcast is published to all clients when there is any change among the orders in the ‘n’ level. However the system is configured to limit the number of broadcast to 4 times a second.
{ BdxPriceLevel : {
"sid" : string,
"levels" : integer,
"buySide" : [ {
"price" : long,
"quantity" : integer
} ],
"sellSide" ; [ {
"price" : long,
"quantity" : integer
} ]
}
}
Description: The Best Bid/Offer broadcast is is disseminated to connected wss clients when there is a change to the best Bid/Offer price or volume.
{ BdxBBO : {
"sid" : string,
"bid" : long,
"bidQty" : integer,
"offer" : long,
"offerQty" : integer
}
}