Market Data Streaming
Authentication
In order to connect to GTN API PRICE STREAMING UAT, setup a webSocket connection should be established to this endpoint,
wss://price-uat.feedgma.com/websocket/price
In order to authenticate yourself you need to get a valid access token from Auth services and send it as a JSON object in the body of a normal message through the web socket connection.
Price streaming only support for customer token only.
- request
- Response
{
"token": "auth_token"
}
{
"EXCHANGES": {
"AMEX": {
"VER": "0,0",
"PRMS": "0,1"
},
"TDWL": {
"VER": "0,0",
"PRMS": "0,1"
},
"ADSM": {
"VER": "0,0",
"PRMS": "0,1"
},
"SGX": {
"VER": "0,0",
"PRMS": "0,1"
},
"XCHI": {
"VER": "0,0",
"PRMS": "0,1"
},
"NSDQ": {
"VER": "0,0",
"PRMS": "0,1"
},
"HKEX": {
"VER": "0,0",
"PRMS": "0,1"
},
"NYSE": {
"VER": "0,0",
"PRMS": "0,1"
},
"DFM": {
"VER": "0,0",
"PRMS": "0,1"
},
"KSE": {
"VER": "0,0",
"PRMS": "0,1"
},
"S\u0026P": {
"VER": "0,0",
"PRMS": "0,1"
},
"CASE": {
"VER": "0,0",
"PRMS": "0,1"
}
},
"CLIENT_IP": "10.212.138.117",
"STAT": "1",
"SERVER_ID": "GTN_API_NEW:026",
"MT": "-1",
"SESSION": "MFS_UAT/3654730509835184",
"COMPRESSION_STATUS": "0",
"SERVER_VER": "0.0.0"
}
Response contains allowed services and exchanges for the particular customer.
Additional Notes
After getting an access token user can send it in json format as shown in the site.
- If what user sends is not in json format, the websocket will simply disconnect.
After getting authenticated, user can send the different message types (MTs q, t, e, p, o) as shown in the site to subscribe for that detail of specific symbol.
User will be checked for authorization based on whether the exchange/symbol is allowed for the user as well as if the current subscription count has exceeded the maximum number of subscriptions allowed for the user. If either of the above is violated, user will get “Unauthorized exchange/symbol or subscription count exceeded” message.
If an incorrect request in valid json format is sent by the user, that message will be simply ignored. But for a request in invalid json format, the Websocket will simply disconnect.
Request Parameters
Request Parameter | Description |
---|---|
RT | Request Type – sub / unsub |
MT | Message Type – q / e / t / p / o |
SYMS | Required symbols list (format - exchange~symbol or exchange~symbol~asset_class_id), if only exchange name is there (like in MT_EXCHANGE) only exchange name is required. Note: maximum list size is five. if you want to subscribe more than five symbols, put same message with remaining. |
APM | Additional Parameter |
{
"RT": request-type,
"MT": message-type,
"SYMS": symbol-list,
"APM": additional-parameters,
}
What is an Asset Class ?
An asset class is a group of investments that exhibit similar characteristics and are subject to the same laws and regulations. Equities, fixed income, options, commodities, and currencies are common examples of asset classes.
How to obtain the "asset_class_id" of a given symbol ?
ASSET_CLASS_ID can be obtained from here.
ASSET_CLASS_ID | Asset Class |
---|---|
7 | Forex |
8 | Index |
Message Type
Message Type | Description |
---|---|
q | Current status of a particular symbol including details such as last traded price, total volume traded and turnover. |
t | When a trade occurs for a particular symbol, details related to that trade such as price and quantity are sent under this message type. |
e | A summary of a particular exchange including details such as total volume, turnover, market status (open/close) can be checked from this message type. |
p | This shows the order book including the buy and sell orders that have been placed at different prices for a given symbol (The levels of the order book include orders placed at different prices combining orders, if there are multiple orders at the same price) |
o | This also shows the order book as above (The levels of the order book include each order separately, doesn't combine orders with same price) |
Sample for realtime & delayed for (q, e , t) -
- Realtime
- Delayed
{
"RT": "sub",
"MT": "q",
"SYMS": [
"ADSM~CHKWINAV~8",
"PFX~USDEUR~7"
]
}
{
"RT": "sub",
"MT": "q",
"SYMS": [
"ADSM~CHKWINAV~8",
"PFX~USDEUR~7"
],
"D":1
}
Market data is delayed by 15 mins for delayed requests.
MT_SNAPSHOT (MT : q)
For Index and Forex -
{
"RT": "sub",
"MT": "q",
"SYMS": [
"ADSM~CHKWINAV~8",
"PFX~USDEUR~7"
]
}
If a symbol contain backslash ( \ ) character, it needs to be replaced by double backslash ( \ ) when included in the symbols list (Ex. for Futures).
{
"RT": "sub",
"MT": "q",
"SYMS": [
"COMEX~EHR\\K23"
]
}
{
"MT": "q",
"e": "NSDQ",
"s": "AAPL",
"sf": 1,
"a": 152.19,
"aq": 400,
"b": 152.11,
"bq": 300,
"hi": 155.04,
"lo": 152.28,
"cls": 152.95,
"op": 154.01,
"c": 0,
"pc": 0,
"pcls": 152.95,
"to": 24514616.6241,
"v": 159928,
"t": 200000,
"p": 152.95,
"q": 0,
"nt": 2853,
"ltd": 20220725,
"vw": 153.2853,
"max": 0,
"min": 0,
"h52": 182.94,
"l52": 129.04,
"hdt52": 20220104,
"ldt52": 20220616,
"mc": 2493974540300,
"lud": 20220725
}
Response Fields
Response Parameter | Description | Parameter Type |
---|---|---|
e | Exchange | String |
s | Symbol | String |
sf | Snapshot | Frame Long |
a | Best Ask | Double |
aq | Best Ask Qty | Long |
b | Best Bid | Double |
bq | Best Bid Qty | Long |
hi | High | Double |
lo | Low | Double |
cls | Close | Double |
op | Open | Double |
c | Change | Double |
pc | Pct Change | Double |
pcls | Prev Closed | Double |
to | Turnover | Double |
v | Volume | Long |
t | Trade Time | Long |
p | Trade Price | Double |
q | Trade Qty | Long |
nt | No of Trades | Long |
ltd | Last Traded Date | Long |
vw | Trade Vwap | Double |
max | Max Price | Double |
min | Min Price | Double |
h52 | Wk 52 High | Double |
l52 | Wk 52 Low | Double |
hdt52 | Wk 52 High Date | Long |
ldt52 | Wk 52 Low Date | Long |
mc | Marketcap | Double |
lud | Last Updated Date | Double |
MT_EXCHANGE (MT : e)
{
"RT": "sub",
"MT": "e",
"SYMS": [ "TDWL", "LSE", "NSDQ"]
}
{
"MT": "e",
"e": "HKEX",
"sf": 1,
"to": 96382874365,
"v": 257900738400,
"nu": 0,
"nd": 0,
"nc": 0,
"st": 0,
"nt": 1594992,
"ms": "close",
"md": 20220726,
"mt": 80839,
"mc": 0
}
Response Fields
Response Parameter | Description | Parameter Type |
---|---|---|
e | Exchange | String |
sf | Snapshot Frame | Long |
to | Turnover | Double |
v | Volume | Long |
nu | No Ups | Long |
nd | No Downs | Long |
nc | No Change | Long |
st | Sym Traded | Long |
nt | No of Trades | Long |
ms | Mkt Status | String |
md | Mkt Date | Long |
mt | Mkt Time | Long |
mc | Marketcap | Double |
MT_COMBINED_TRADE (MT : t)
{
"RT": "sub",
"MT": "t",
"SYMS": [
"TDWL~1010",
"NSDQ~AAPL",
"LSE~LLOY" ],
"APM": {
"BKL": "20"
}
}
{
"MT": "t",
"e": "DFM",
"s": "TABREED",
"t": 72415,
"tsq": 802,
"p": 2.72,
"q": 6750,
"pc": -1.449,
"c": -0.04,
"ts": 1
}
Response Fields
Response Parameter | Description | Parameter Type |
---|---|---|
e | Exchange | String |
s | Symbol | String |
sf | Snapshot Frame | Long |
ts | Trade Splits | Long |
t | Trade Time | Long |
tsq | Trade Sequence | Long |
p | Trade Price | Double |
q | Trade Qty | Long |
c | Change | Double |
pc | Pct Change | Double |
MT_DEPTH_PRICE (MT : p)
{
"RT": "sub",
"MT": "p",
"SYMS": [
"DFM~DIB",
"LSE~LLOY",
"HKEX~3800"
]
}
{
"MT": "p",
"e": "HKEX",
"s": "3800",
"sd": "b",
"l": 1,
"p": 3.6,
"q": 6705000,
"sp": 189,
"sd": "a",
"l": 10,
"p": 0.0,
"q": 0,
"sp": 0,
"sd": "b",
"l": 10,
"p": 0.0,
"q": 0,
"sp": 0,
"sd": "b",
"l": 11,
"p": 0.0,
"q": 0,
"sp": 0,
"sd": "a",
"l": 11,
"p": 0.0,
"q": 0,
"sp": 0
}
Response Fields
Response Parameter | Description | Parameter Type |
---|---|---|
e | Exchange | String |
s | Symbol | String |
sd | MBP Type | String |
l | MBP POS | Long |
p | MBP Price | Double |
q | MBP Qty | Long |
sp | MBP Splits | Long |
MT_DEPTH_ORDER (MT : o)
{
"RT": "sub",
"MT": "o",
"SYMS": [
"DFM~DIB",
"LSE~LLOY",
"HKEX~3800"
]
}
{
"MT": "o",
"e": "NSDQ",
"s": "AMZN",
"sd": "b",
"l": 0,
"p": 99.99,
"q": 6,
"sd": "a",
"l": 0,
"p": 100,
"q": 100,
"sd": "b",
"l": 1,
"p": 99.98,
"q": 13,
"sd": "a",
"l": 1,
"p": 100,
"q": 100,
"sd": "b",
"l": 2,
"p": 99.98,
"q": 80,
"sd": "a",
"l": 2,
"p": 100,
"q": 60,
"sd": "b",
"l": 3,
"p": 99.98,
"q": 90,
"sd": "a",
"l": 3,
"p": 100,
"q": 300
}
Response Fields
Response Parameter | Description | Parameter Type |
---|---|---|
e | Exchange | String |
s | Symbol | String |
sd | MBO Type | String |
l | MBO POS | Long |
p | MBO Price | Double |
q | MBO Qty | Long |
Sandbox environment
contains delayed data & 1 user can only have up to 50 subscriptions at a given time.
Currently, for the streaming API in the UAT canned feed environment, only a selected set of symbols are enabled for different exchanges as below.
Exchange Code | Exchange | Symbols |
---|---|---|
NSDQ | NASDAQ Stock Exchange | AAPL, BRK.A, GOOG, JPM, META, AMZN, BAC, PYPL, NVDA, SMMT, BYSI, RIVN, WBD, SOFI, VKTX, CSX, NKLA, TLRY, LYFT, GRAB, MARA, DKNG, PARA, HOOD, AFRM, LCID, MDGL, DOCU, KDP, VTRS, COSM, COIN, CSCO, FCEL, HBAN, AMD, AMRS, MRVL, QCOM, SIRI, PLUG, MSFT, AAL, EBAY, MU, JBLU, INTC |
NYSE | The New York Stock Exchange | IBM, WMT, KO, TM, DIS, NKE, MCD, V, CVX, MA, F, T, CCL, PLTR, BAC, UBER, AMC, VZ, ATUS, NU, SNAP, FTCH, C, WFC, CVNA, LUMN, GOLD, PFE, CHPT, SWN, ET, SHOP, PCG, XOM, KMI, AJRD, RBLX, RIG, NYCB, HBI, GM, USB, NCLH, M, KEY, CLF, MRO, OXY, U, CRM, MDT, SQ, FCX, CTRA, HPE, JPM, DAL, BMY, MO, ORCL |
AMEX | NYSE American | FAX, ACU, AE, ADRA, TELL, AGE, AIM, AAU, ERH, ERC |
LSE | London Stock Exchange | LLOY, BARC, GLEN, HSBA,RR., VOD,BP., WBI, SEE, BOO |
XASX | Australian Stock Exchange | PLS, LNK, ADD, BHP, RIO, CBA, CSL, NAB, WBC, FMG |
XNZE | Newzealand Stock Exchange | MEL, AIA, CEN, SKC, SPK, GNE, FPH, MCY, BGP, IFT |
HKEX | Hongkon Stock Exchange | 1765, 8083, 2048, 1773, 1797, 136, 493, 3800, 6169, 1610 |
SGX | Singapore Stock Exchange | S51, BS6, YF8, Y92, Z74, C8R, N04, E5H, G13, 5WH |
CNSGSE | Shanghai Stock Exchange | 600023, 600216, 600077, 601633, 603259, 601899, 600887, 600438, 600000, 601919 |
XTKS | Tokyo Stock Exchange | 7203, 9984, 6758, 9432, 6861, 8035, 4063, 9983, 9434, 7974 |
XSHE | Shenzhen Stock Exchange | 000002, 002415, 000001, 000009, 000012, 000021, 000027, 000028, 000032 |
HSTC | Hanoi Stock Exchange | PVS, BII, AAV, AMC, AME, BLF, AMV, API, ACM, ADC, ALT, BKC |
XKRX | Korea Stock Exchange | 005930, 373220, 000660, 207940, 051910, 005380, 035420, 006400, 035720, 000270 |
XBKK | Thailand Stock Exchange | PTT, AOT, PTTEP, ADVANC, CPALL, GULF, SCC, BDMS, DELTA, MAKRO |
XTAI | Taiwan Stock Exchange | 2603, 2498, 3481, 2618, 2303, 2609, 2610, 3035, 2482, 6118 |
XKLS | Borsa Malaysia Stock Exchange | YONGTAI, TOPGLOV, MTRONIC, WIDAD, SAPNRG, JADEM, DNEX, HIBISCS, MGRC, NWP |
XIDX | Indonesian Stock Exchange | ARTO, BUMI, GOTO, ZINC, BBCA, BBRI, BUKA, SWAT, BMTR, UNTR |
GTISEP | Commodities (Brent Oil/Crude) | EBROUSDBR.SP, EWTIUSDBR.SP |
GTISPM | Commodities (Metal) | SXAUUSDOZ.SP, SXPDUSDOZ.SP, SXPTUSDOZ.SP, SXAGUSDOZ.SP |
PFX | Forex | USDAED, USDAUD, USDBDT, USDBHD, USDCAD, USDCHF, USDCNY, USDEGP, USDEUR, USDGBP, USDHKD, USDIDR, USDINR, USDJPY, USDJOD, USDKWD, USDLBP, USDLKR, USDMAD, USDMYR, USDNZD, USDOMR, USDPHP, USDPKR, USDQAR, USDRUB, USDSAR, USDSGD, USDKRW, USDTWD, USDTHB, USDTND, USDTRY, USDZAR, USDVND |
S&P | S&P Index | I:SP500 |
NSDQGI | NASDAQ general Index | I:NDX |
DJI | Dow Jones Index | DJIA |
XCHI | NYSE Chicago | KNOP, AAPL, GDX, MSGE, GAINZ, REVB, VVX, SPXL, NINE, IEFA |
CHIX | CHI-X Europe Stock Exchange | BPL, AZNL, SHELL, DGEL, GLENL, HSBAL, RIOL, GSKL, BARCL, LSEGL |
But for the below markets all the symbols are enabled.
Exchange Code | Exchange |
---|---|
TDWL | Saudi Stock Exchange |
DFM | Dubai Financial Market |
DSM | Qatar Stock Exchange |
CASE | Egypt Stock Exchange |
ADSM | Abu Dhabi Stock Exchange |
DIFX | NASDAQ Dubai |
MSM | Muscat Stock Exchange |
Web Socket Client example
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();
}
}