IDS supports the following environments :
1.Net
2.Javascript
3.Python
4.Java
Data Streaming in TradingAPI is taken care by its sub-system, Information Distribution Service (IDS). IDS is a subscription basis data pushing facility. This version of IDS focuses on the streaming of market data as well as status of active orders. In the near future, more information will be added such as company profile, back testing facilities, and others
Channels :
Securities Status : F
Stock Price : X
Foreign Room : R
Index Information : MI
Ohlc Information : B
ALL : ALL
No. |
Name of Element |
Type |
Description |
Value Value/Format |
1. |
RType |
String |
This is a fixed value to identify the value of this record for what type of information |
F – Securities Status |
2. |
MarketID |
String |
The ID of the corresponding Exchange where the equity is trading. |
- HOSE - HNX - HNXBOND - UPCOM - DER |
3. |
ReportDate |
Date |
Date & time of the data record. |
DDMMYYYY 24HHMISS |
4. |
Symbol |
String |
Ticker of the securities |
|
5. |
TradingSession |
String |
Session status of the market |
Having the following value: - ATO: Opening Call Auction - LO: Continuous Trading - ATC: Closing Call Auction - PT: Putthrough - CLOSE: Market Close - BREAK: Lunch Break - HALT: Market Halt |
6. |
TradingStatus |
String |
|
|
No. |
Name of Element |
Type |
Description |
Valid Value or Format |
1. |
Rtype |
String |
|
X: Stock price |
2. |
TradingDate |
Date |
|
|
3. |
Time |
Time |
|
|
4. |
ISIN |
String |
ISIN code |
|
5. |
Symbol |
String |
Local ticker |
|
6. |
Ceiling |
Number |
Ceiling price |
|
7. |
Floor |
Number |
Floor price |
|
8. |
RefPrice |
Number |
Reference price |
|
9. |
Open |
Number |
The opening price of the equity |
|
10. |
Close |
Number |
The closing price of the equity |
|
11. |
High |
Number |
Highest matched price in the date of report |
|
12. |
Low |
Number |
Lowest matched price in the date of report. |
|
13. |
Avg |
Number |
Average price of the security |
|
14. |
PriorVal
|
Number |
The closing price of previous trading day of the report date. |
|
15. |
LastVal |
Number |
Latest matched price |
|
16. |
LastVol |
Number |
Latest matched volume |
|
17. |
TotalVal |
Number |
Total matched value from market opening till the reporting time. |
|
18. |
TotalVol |
Number
|
Total matched volume from market opening till the reporting time. |
|
19. |
BidPrice1 |
Number |
Best bid price 1 |
|
20. |
BidVol1 |
Number |
Best bid volume 1 |
|
21. |
BidPrice2 |
Number |
Best bid price 2 |
|
22. |
BidVol2 |
Number |
Best bid volume 2 |
|
23. |
BidPrice3 |
Number |
Best bid price 3 |
|
24. |
BidVol3 |
Number |
Best bid volume 3 |
|
25. |
BidPrice4 |
Number |
Best bid price 4 |
|
26. |
BidVol4 |
Number |
Best bid volume 4 |
|
27. |
BidPrice5 |
Number |
Best bid price 5 |
|
28. |
BidVol5 |
Number |
Best bid volume 5 |
|
29. |
BidPrice6 |
Number |
Best bid price 6 |
|
30. |
BidVol6 |
Number |
Best bid volume 6 |
|
31. |
BidPrice7 |
Number |
Best bid price 7 |
|
32. |
BidVol7 |
Number |
Best bid volume 7 |
|
33. |
BidPrice8 |
Number |
Best bid price 8 |
|
34. |
BidVol8 |
Number |
Best bid volume 8 |
|
35. |
BidPrice9 |
Number |
Best bid price 9 |
|
36. |
BidVol9 |
Number |
Best bid volume 9 |
|
37. |
BidPrice10 |
Number |
Best bid price 10 |
|
38. |
BidVol10 |
Number |
Best bid volume 10 |
|
39. |
AskPrice1 |
Number |
Best Ask price 1 |
|
40. |
AskVol1 |
Number |
Best Ask volume 1 |
|
41. |
AskPrice2 |
Number |
Best Ask price 2 |
|
42. |
AskVol2 |
Number |
Best Ask volume 2 |
|
43. |
AskPrice3 |
Number |
Best Ask price 3 |
|
44. |
AskVol3 |
Number |
Best Ask volume 3 |
|
45. |
AskPrice4 |
Number |
Best Ask price 4 |
|
46. |
AskVol4 |
Number |
Best Ask volume 4 |
|
47. |
AskPrice5 |
Number |
Best Ask price 5 |
|
48. |
AskVol5 |
Number |
Best Ask volume 5 |
|
49. |
AskPrice6 |
Number |
Best Ask price 6 |
|
50. |
AskVol6 |
Number |
Best Ask volume 6 |
|
51. |
AskPrice7 |
Number |
Best Ask price 7 |
|
52. |
AskVol7 |
Number |
Best Ask volume 7 |
|
53. |
AskPrice8 |
Number |
Best Ask price 8 |
|
54. |
AskVol8 |
Number |
Best Ask volume 8 |
|
55. |
AskPrice9 |
Number |
Best Ask price 9 |
|
56. |
AskVol9 |
Number |
Best Ask volume 9 |
|
57. |
AskPrice10 |
Number |
Best Ask price 10 |
|
58. |
AskVol10 |
Number |
Best Ask volume 10 |
|
No. |
Name of Element |
Type |
Description |
Valid Value or Format |
1. |
Rtype |
String |
Message type |
R: Foreign room |
2. |
TradingDate |
Date |
|
|
3. |
Time |
Time |
|
|
4. |
ISIN |
String |
ISIN code |
|
5. |
Symbol |
String |
Local ticker |
|
6. |
TotalRoom |
Number |
Available no of shares for foreign trading. |
|
7. |
CurrentRoom
|
Number |
Total matched volumes which foreigner brought from market opening till the reporting time. |
|
8. |
FBuyVol |
Number |
Total matched volumes which foreigner buy from market opening till the reporting time. |
|
9. |
FSellVol |
|
Total matched volumes which foreigner sold from market opening till the reporting time. |
|
10. |
FBuyVal |
Number |
Total matched buy value of foreign customers |
|
11. |
FSellVal |
Number |
Total matched sell value of foreign customers |
|
No |
Name of Element |
Tyoe |
Description |
Valid value |
1. |
Rtype |
String |
Message Type |
MI: Index Information |
2. |
IndexID |
String |
Index ID |
|
3. |
IndexValue |
Number |
Value of the index |
|
4. |
Trading Date |
Date |
Trading Date |
|
5. |
Time |
Timestamp |
Time |
|
6. |
Change |
Number |
Change of index |
|
7. |
RatioChange |
Number |
Ratio of Change |
|
8. |
TotalTrade |
Number |
Tổng số lệnh khớp (cả thông thường và thỏa thuận) |
|
9. |
TotalMatchQtty |
Number |
Tổng matched quantity of normal orders |
|
10. |
TotalMatchValue |
Number |
Tổng matched value of normal orders |
|
11. |
TypeIndex |
String |
Index |
“Main” – main index such as VN30 “Industry” – industrial related index “Other” – non classified index. |
12. |
IndexName |
String |
Name of Index |
|
13. |
Advances |
Number |
Total number of symbols having price increase |
|
14. |
Nochanges |
Number |
Total number of symbols having price unchange |
|
15. |
Declines |
Number |
Total number of symbols having price decrease |
|
16. |
Ceiling |
Number |
Total number of symbols having last price = ceiling price |
|
17. |
Floor |
Number |
Total number of symbols having last price = floor price |
|
18. |
TotalMatchQttyPT |
Number |
Total matched quantity of puthrough orders |
|
19. |
TotalMatchValuePT |
Number |
Total matched value of putthrough orders |
|
20. |
TotalVol |
Number |
Total matched quantity of both normal and putthrough |
|
21. |
TotalVal |
Number |
Total matched value of both normal and putthrough |
|
22. |
TradingSession |
String |
Trading session |
- ATO: ATO |
- LO: Continuous |
||||
- ATC: ATC |
||||
- PT: Putthrough |
||||
- Break: lunch break |
||||
- C: Market Close |
||||
- H: Market halted |
||||
23. |
Market |
String |
Market |
- HOSE - HNX - UPCOM - DER: Derivatives |
24. |
Exchange |
String |
Exchange |
- HOSE - HNX |
No. |
Name of Element |
Type |
Description |
Valid Value or Format |
1. |
Rtype |
String |
Message Type |
b: OHLC information |
2. |
Time |
Timestamp |
Include date and time |
|
3. |
Symbol |
String |
Local ticker |
Include both Index, Stock and Derivatives |
4. |
Open |
Number |
Open price |
|
5. |
High |
Number |
Highest price |
|
6. |
Low |
Number |
Lowest price |
|
7. |
Close |
Number |
Close price |
|
8. |
Volume |
Number |
Matched Volume |
|
9. |
Value |
Number |
Matched Value |
|
To use the order stream, client need to init the stream and then bind to subcribe the update
client.initStream({
url: config.stream_url,
consumer_id: config.ConsumerID,
consumer_secret: config.ConsumerSecret,
notify_id : 0
});
Note: when server disconnected: notify_id = 0 return data from the start day, notify_id = -1 return data from reconnected, notify_id = n return data from n
client.bind(client.events.onOrderUpdate, function (e,data) {
console.log(e + ": ");
console.log(JSON.stringify(data));
});
client.bind(client.events.onOrderError, function (e, data) {
console.log(e + ": ");
console.log(JSON.stringify(data));
});
Name of Element |
Type |
Required |
Description |
Valid Value or Format |
uniqueid |
String |
|
|
|
connectionid |
String |
|
|
|
ipaddress |
String |
|
To detect the request from client to TAPI |
|
notifyid |
String |
|
The serial number of msg |
|
orderid |
String |
|
|
|
instrumentid |
String |
|
Stock symbol |
|
buysell |
String |
|
|
- B: Buy - S: Sell |
ordertype |
String |
|
|
- LO - ATO - ATC - MP - MTL - MOK - MAK - PLO |
price |
Number |
|
|
|
quantity |
Number |
|
|
|
marketid |
String |
|
|
|
origrequestid |
String |
|
|
|
account |
String |
|
|
|
cancelqty |
Number |
|
Total quantity was cancelled |
|
osqty |
Number |
|
Total quantity was not matched |
|
filledqty |
Number |
|
Total quantity was matched |
|
avgprice |
Number |
|
|
|
channel |
String |
|
|
|
inputtime |
String |
|
|
HH:mm:ss |
modifiedtime |
String |
|
|
HH:mm:ss |
isforcesell |
Boolean |
|
|
|
isshortsell |
Boolean |
|
|
|
orderstatus |
String |
|
|
- WA: WaitingApproval - RS: ReadyToSendExchange - SD: SentToExchange - QU: QueueInExchange - FF: FullyFilled - PF: PartiallyFilled - FFPC: FullyFilledPartiallyCancelled - WM: WaitingModify - WC: WaitingCancel - CL: Cancelled - RJ: Rejected - EX: Expired - SOR: StopOrderReady - SOS: StopOrderSent - IAV: PreSessionOrder - SOI: PreSessionStopOrder |
OrigOrderId |
String |
|
The order id of the parent conditional order |
|
rejectreason |
String |
|
|
|
Example:
New order
New Order Input |
Streaming Output |
data: { requestid: “88011140", requestdata: { instrumentid: "SSI", market: "VN", buysell: "B", ordertype: "LO", channelid: "XL", price: "24200", quantity: "50", account: "0163271" } }
|
{"data": "","uniqueid":"88011140", "connectionid":"2d5af2a7a81a4f4f88d4ba3ac865ae64", "ipaddress":"192.168.202.36","notifyevent": {"orderevent": {“notifyid”:”545”, "orderid":"8747582", "instrumentid":"SSI", "buysell":"B", "ordertype":"LO", "price":"24,200", "quantity":"50", "marketid":"VN", "origorderid":"", "account":"0163271", "cancelqty":"0", "osqty":"50", "filledqty":"0", "avgprice":"0", "channel":"N", "inputtime":"20190712-151432", "modifiedtime":"1562919273000", "isforcesell":"F", "isshortsell":"F", "orderstatus":"RS", “rejectreason”:”0”, "neworder":{} }}} |
Case newOrder has error:
{"data":"","uniqueid":"90545362","connectionid":"eeee5d053df0457ab03c48c5656445fe","ipaddress":"192.168.202.36","notifyevent":{"notifyid":531,"ordererror":{"message":"Order price lower limit can not exceed spread limit","errorcode":"ORD002"}}}
Modify Order
Modify Input |
Streaming Output |
data: { requestid: "34726460", requestdata: { orderid: “8747582” instrumentid: "SSI", market: "VN", buysell: "B", ordertype: "LO", price: "24500", quantity: "50", account: "0163271"} }
|
{"data": "","uniqueid":"34726460", "connectionid":"2d5af2a7a81a4f4f88d4ba3ac865ae64", "ipaddress":"192.168.202.36","notifyevent": {"orderevent": {“notifyid”:”578”, "orderid":"8747582", "instrumentid":"SSI", "buysell":"B", "ordertype":"LO", “price":"24,500", "quantity":"450", "marketid":"VN", "origorderid":"", "account":"0163271", "cancelqty":"0", "osqty":"450", "filledqty":"0", "avgprice":"0", "channel":"N", "inputtime":"20190715-132154", "modifiedtime":"1563171865000", "isforcesell":"F", "isshortsell":"F", "orderstatus":"WM", “rejectreason”:”0”, "ordermodified":{} }}} |
Case modifyOrder has error:
{"data":"","uniqueid":"90545366","connectionid":"eeee5d053df0457ab03c48c5656445fe","ipaddress":"192.168.202.36","notifyevent":{"notifyid":535,"ordererror":{"message":"Order price lower limit can not exceed spread limit","errorcode":"ORD002"}}}
Cancel Order
Cancel Input |
Streaming Output |
data: { requestid: "38396691", requestdata: { orderid:"8747983", market: "VN", instrumentid: "MBB", buysell: "B", account: "0163271", } } |
{"data":"", "uniqueid":"38396691", "connectionid":"2d5af2a7a81a4f4f88d4ba3ac865ae64", "ipaddress":"192.168.202.36","notifyevent": {"orderevent": {“notifyid”: “560”, "orderid":"8747983", "instrumentid":"MBB", "buysell":"B", "ordertype":"LO", "price":"21,300", "quantity":"100", "marketid":"VN", "origorderid":"", "account":"0163271", "cancelqty":"0", "osqty":"50", "filledqty":"50", "avgprice":"21300.0", "channel":"N", "inputtime":"20190716-135027", "modifiedtime":"1563260590000", "isforcesell":"F", "isshortsell":"F", "orderstatus":"CR", “rejectreason”:”0”, "orderpendingcancel":{} }}} |
Case cancel has error:
{"data":"","uniqueid":"80036291","connectionid":"eeee5d053df0457ab03c48c5656445fe","ipaddress":"192.168.202.36","notifyevent":{"notifyid":551,"ordererror":{"message":"Invalid State To Cancel Order Error!","errorcode":"ERR500"}}}
Name of Element |
Type |
Required |
Description |
Valid Value or Format |
UniqueID |
String |
|
Original request ID |
|
ConnectionID |
String |
|
|
|
IPAddress |
String |
|
To detect the request from client to TAPI |
|
notifyid |
String |
|
The serial number of msg |
|
ErrorCode |
String |
|
One of the error code defined in the list |
|
Message |
String |
|
Corresponding error msg |
|
Example:
{"data":"","uniqueid":"6309248","connectionid":"2d5af2a7a81a4f4f88d4ba3ac865ae64","ipaddress":"192.168.202.36","notifyevent":{ “notifyid”: 550,"ordererror":{"message":"This order cannot be modified", "errorcode":"ORD001"}}}
To use the porfolio stream, client need to init the stream and then bind to subcribe the update
client.bind(client.events.onClientPortfolioEvent,function(e,data){
//Process data...
console.log(e + ": ");
console.log(JSON.stringify(data));
})
Name of Element |
Type |
Required |
Description |
Valid Value or Format |
uniqueid |
string |
|
|
|
connectionid |
String |
|
|
|
ipaddress |
String |
|
To detect the request from client to TAPI |
|
notifyid |
String |
|
Id of message |
|
account |
|
|
accountid |
|
clientporfoliosopenList |
||||
marketid |
String |
|
|
VNFE |
instrumentid |
String |
|
Stock symbol |
|
longqty |
number |
|
Long position |
|
shortqty |
number |
|
Short position |
|
net |
number |
|
Net position |
|
bidavgprice |
number |
|
Average bid price |
|
askavgprice |
number |
|
Average ask price |
|
tradeprice |
number |
|
Trade price |
|
marketprice |
number |
|
Maket price |
|
floatingpl |
number |
|
Temporarily calculated profit and loss |
|
tradingpl |
number |
|
Calculated profit and loss |
|
clientporfolioscloseList |
||||
marketid |
String |
|
|
|
instrumentid |
String |
|
Stock symbol |
|
longqty |
number |
|
Long position |
|
shortqty |
number |
|
Short position |
|
net |
number |
|
Net position |
|
bidavgprice |
number |
|
Average bid price |
|
askavgprice |
number |
|
Average ask price |
|
tradeprice |
number |
|
Trade price |
|
marketprice |
number |
|
Maket price |
|
floatingpl |
number |
|
Temporarily calculated profit and loss |
|
tradingpl |
number |
|
Calculated profit and loss |
|
Example:
{"data":"","uniqueid":"","connectionid":"","ipaddress":"","notifyevent":{"notifyid":2972,"clientportfolioevent":{"account":"0032528","clientportfoliosopenList":[{"martketid":"VNFE","instrumentid":"VN30F1907","longqty":"3","shortqty":"0","net":"3","bidavgprice":"0","askavgprice":"0","tradeprice":"881.8","marketprice":"881.84","floatingpl":"0","tradingpl":""},{"martketid":"VNFE","instrumentid":"VN30F1909","longqty":"76","shortqty":"0","net":"76","bidavgprice":"0","askavgprice":"0","tradeprice":"881.8","marketprice":"881.84","floatingpl":"0","tradingpl":""}],"clientportfolioscloseList":[{"martketid":"VNFE","instrumentid":"VN30F1909","longqty":"1","shortqty":"0","net":"1","bidavgprice":"0","askavgprice":"0","tradeprice":"881.8","marketprice":"881.84","floatingpl":"","tradingpl":"0"},{"martketid":"VNFE","instrumentid":"VN30F1909","longqty":"0","shortqty":"1","net":"-1","bidavgprice":"0","askavgprice":"0","tradeprice":"900","marketprice":"881.84","floatingpl":"","tradingpl":"0"}]}}}