Skip to main content
Version: 1.0.0

Trade Streaming

This component creates a web socket with clients. Once established the Clients can receive trade updates through this service.

How to connect

In order to connect to GTN API TRADE STREAMING UAT, setup a WebSocket connection should be established to the following endpoint,

wss://gtn-api-uat.globaltradingnetwork.com/websocket

Authenticate

Once a Websocket connection is established, the program is required to send a message with token information as following for authentication purposes.

{
"token": "auth_token"
}

Users cannot do anything without getting authenticated with GTN. Socket connection will be closed within 1 min if the authentication process has failed.

A server token or a customer token can be used; to connect to trade streaming. However only 1 server token will be support at any given time for an institution.

A valid token must be used to establish socket connection.

Heartbeat

After creating a web socket, the web socket client is required to send a heartbeat pulse (recommend ; 1 pulse/30 s) to the server. If a heartbeat message is not received within 1 min period, the server will close Websocket session.

The client application is required to send following message a heartbeat and the sever will respond to each with same message.

h

Responses

{

"orderNumber": "XXXXXX",
"orderId": "XX",
"originalOrderId": "XX",
"exchange": "XXX",
"symbol": "XXXX",
"accountNumber": "XXXXX",
"orderSide": "X",
"orderType": "X",
"averagePrice": X.X,
"orderQty": XX.X,
"filledQty": XX.X,
"orderValue": XXX.X,
"netOrderValue": XXX.X,
"filledOrderValue": X.X,
"commission": X.X,
"createdDate": "yyyy/MM/dd-HH:mm:ss",
"rejectReason": "XXXXXXX",
"orderStatus": "X",
"institutionCode": "XXXXX",
"customerNumber": "XXX",
"tif": "X",
"executionId": "XX"

}

Web Socket Client sample code

export class WebsocketService {

websocket: WebSocket | undefined;
public webSocketMessage: string[] = [];

constructor() { }

openWebSocketConnection(url:string){
this.websocket = new WebSocket(url);

this.websocket.onopen = (e)=>{
console.log(e);
}

this.websocket.onmessage = (e) =>{
console.log(e);
this.webSocketMessage.push(e.data);
}

this.websocket.onclose= (e)=>{
console.log(e);
}
}

sendWebSocketMessage(msg: string){
if(this.websocket!= undefined)
this.websocket.send(JSON.stringify(msg));
}

closeWebSocketConnection(){
if(this.websocket!= undefined)
this.websocket.close();
}

}
Is this page helpful for you?