Professional Documents
Culture Documents
Net
(Detailed understanding and Implementation guide)
Contents
1. General Guidelines .................................................................................................................. 3
1. GENERAL GUIDELINES
Connection Modes: -
There are 2 modes available to receive Broadcast,
o INTERNET - TCP Only
o Leased Lines\ VSAT- Mixed Multicast
TCP Only: We generally use this type of connection for INTERNET standalone terminals;
here feed is received via TCP connection once established with the server, with the
provided IP: PORT credentials, only for those scrips which are registered. Both feed data
components, i.e. snapshot and live feed is received on the same TCP connection.
Mixed Multicast: We use this type of connection for Leased Lines, Local network or
VSAT; here live feed is received via Multicast Group on provided GROUP IP: PORT
credentials, for ALL SCRIPS as well as for snapshot of a scrip, we also need to establish a
TCP connection with the server with provided IP: PORT credentials and register the same.
NOTE –
• Login Packet is mandatory to be sent to the server on every successful establishment of
TCP connection or re connection.
• In TCP Only, to receive feed for scrip, registration request of that scrip is mandatory.
• The data received on Multicast socket is compressed, ref De Compression
• In case of VSAT, for NSE FO user may not receive ALL SCRIPS broadcast feed, but only for
registered scrips, or amongst superset of all scrips registered across all the users.
Header Body
Byte 1 10 30
3. BROADCAST API
This is a nested structure and always will be the first field of all structures client will receive from
server.
Name Type Description
Exchange Byte For Exchange Identification, ref Exchange
Identification
Scrip Code Int Scrip Code as per exchange.
Time Int Time at which message is generated in terms of
seconds from 01-01-1980 00:00:00 hours.
Type Byte Type of Record.
Type: - “1”
This is a heartbeat request send from server to client. Client need to respond to this
request by sending heart beat response packet.
Name Type Description
Response Header Response Header
Reserved Byte(20)
Type: - “A”
This will be received by client whenever there is a trade.
Name Type Description
Response Header Response Header
Rate Single Trade price
Qty Int Trade Qty
Cumulative Qty Int Total volume
AvgTradePrice Single Weighted average price
Open Interest Int Open interest (Valid for FnO Only)
Type: - “G”
This will be received by client whenever there is a change in day high/low.
Name Type Description
Response Header Response Header
Open Single Open price
High Single High Price
Low Single Low Price
PrevDayClose Single Close price
Reserved Byte(4) Reserved field
Type: - “H”
This will be received by client whenever there is a change in spot Price for Index.
Name Type Description
Response Header Response Header
Rate Single Trade price
Reserved Byte(16) Reserved Field
Type: - “W”
This will be received by client whenever there is a change in daily price range.
Name Type Description
Response Header Response Header
UpperCktLimit Single Upper range
LowerCktLimit Single Lower range
Reserved Byte(12) Reserved field
Type: - “s”
This will be received by client as a START packet for downloading historical trades.
Name Type Description
Response Header Response Header
History Rec Count Ushort Total No. of historical trades upcoming.
Reserved Byte(18) Reserved field
Type: - “t”
This will be received by client as a Continuation packet for downloading historical trades.
Name Type Description
Response Header Response Header Time field is used for Tick A.
RateA Single Trade Price for Tick A
Qty A Int Trade Qty for Tick A
RateB Single Trade Price for Tick B
Qty B Int Trade Qty for Tick B
Time B Int Time at which message is generated in terms
of seconds from 01-01-1980 00:00:00 hours.
Type: - “u”
This will be received by client as an END packet for downloading historical trades.
Name Type Description
Response Header Response Header
History Over Ushort 1 as end of History receiving
Reserved Byte(18) Reserved field
Type: - “S”
This will be received by client as a START packet for downloading historical OI.
Name Type Description
Response Header Response Header
History Rec Count Ushort Total No. of historical OI upcoming.
Reserved Byte(18) Reserved field
Type: - “T”
This will be received by client as a Continuation packet for downloading historical OI.
Name Type Description
Response Header Response Header Time field is used for Open Interest Tick A.
QtyA Int Open Interest Qty for Tick A
TimeB Int Open Interest Time for Tick B
QtyB Int Open Interest Qty for Tick B
TimeC Int Open Interest Time for Tick C
QtyC Int Open Interest Qty for Tick C
Type: - “U”
This will be received by client as an END packet for downloading historical OI.
Name Type Description
Response Header Response Header
History Over Ushort 1 as end of History receiving
Reserved Byte(18) Reserved field
This is a nested structure and always will be the first field of all structures client will send to
server.
Name Type Description
Msg Type Char Type of message
Msg Len Ushort Length of message excluding request header
Msg Type: - “Q” for first login and “q” for further reconnection if any.
This need to be send as a very first packet after socket connection.
Name Type Description
Request Header Request Header
FEUserIDLength Byte Actual length of Client Code.
FEUserID Char(15) Client Code
FEUserNameLength Byte Actual length of Client name.
FEUserName Char(30) Client name
RequiredNseEquity Byte “1” if Allowed and “0” if not allowed NSE CASH
RequiredNseDeriv Byte “1” if Allowed and “0” if not allowed NSE FO
RequiredBseEquity Byte “1” if Allowed and “0” if not allowed BSE CASH
VersionLength Byte Actual length of Version
Version Char(10) As per provided by MOSL IT – OPERATION
Team
GetAllBO Byte “30” Hardcoded
AllScripsNseCash Byte “0” If connecting with TCP Only Mode,
“1” if connecting with Mixed Multicast Mode.
AllScripsNseDeriv Byte “0” If connecting with TCP Only Mode,
“1” if connecting with Mixed Multicast Mode.
AllScripsBseCash Byte “0” If connecting with TCP Only Mode,
“1” if connecting with Mixed Multicast Mode.
AllowTotalBuySellQty Byte “1” If Total Buy and Sell Qty allowed
“0” in not allowed
Reserved Byte[45] Reserved Space padding
4. INTERACTIVE API
This is a nested structure and always will be the first field of all structures used for
communication.
Message Code – 1 (one). In response user will get message code 2 having different
structure.
Name Type Description
MessageHeader Message This is a nested structure.
Header
UserID Char(20) ID provided by MOSL.
Password Char(16) Password of the ID.
IPAddress Char(16) IPAddress of the system.
MacAddress Char(20) MacAddress of the system.
VersionNo Int Version number of application. Currently it is
34.
PANOrDOB Char(13) PAN number or DOB in dd/mm/yyyy format.
Message Code – 4 (four). In response user will get message code 51 having different
structure.
Message Code –
10 – New Order Request. In response user will get 13(Order Confirm),16(Order Error) or
19(Order Reject). Structure will remain same.
11 – Order Modification. In response user will get 14(Order Modify Confirm),16(Order Error) or
20(Order Modify Reject). Structure will remain same.
12 – Order Cancellation. In response user will get 15(Order Cancell Confirm),16(Order Error) or
21(Order Cancell Reject). Structure will remain same.
Message Code – 34
Message Code –
9 –Order download request. In response user will first get message code 45. Structure will
be same of Message Header. This is to inform user that download is going to start now. After
this user will get multiple packets of message code 32. Structure will be same as request and
at end multiple order packet will come in bunch. Number of order packets will be mention in
NumberOfRecords field of response packet. At the end message code 46 will come. Structure
will be same of Message Header. This is to inform end of order download.
5 –Trade download request. In response user will first get message code 47. Structure will
be same of Message Header. This is to inform user that download is going to start now. After
this user will get multiple packets of message code 33. Structure will be same as request and
at end multiple trade packet will come in bunch. Number of trade packets will be mention in
NumberOfRecords field of response packet. At the end message code 48 will come. Structure
will be same of Message Header. This is to inform end of trade download.
Message Code – 35. In response user will get message code 36.
Message Code – 36
NetOptionPremiumFO Double 0
NetOptionPremiumCurrency Double 0
CreditOptionAmountFO Double 0
CreditOptionAmountCurrency Double 0
Derivative Special Margin Double 0
Derivative Additional Margin Double 0
Currency Special Margin Double 0
Currency Additional Margin Double 0
AvailableFundsforCommodity Double 0
StockCapitalCommodity Double 0
AdditionalCapitalCommodity Double 0
CommoditySpanMargin Double 0
CommodityExposureMargin Double 0
CommoditySpecialMargin Double 0
CommodityAdditionalMargin Double 0
CommodityM2MLoss Double 0
CommodityBPL Double 0
NetOptionPremiumCommodity Double 0
CreditOptionAmountCommodity Double 0
SLBMMarginUsed Double 0
SLBMBPL Double 0
SLBMM2MLoss Double 0
MtfMargin Double 0
MtfLoss Double 0
Brokerage Double 0
15. Holding report request – Length 66 bytes
Message Code – 41. In response user will get message code 42.
Message Code – 42
Message Code –
99 – New Order Request. In response user will get 100(Confirm), 101(Cancell
Confirm),102(Error) or 103(Reject). Structure will remain same.
For multi leg order you should send orders in order1 and order2. Order must be IOC order .
Order3 will be null but packet size will be 861 only. For filling order1 and order2, follow rules
of normal order.
Message Code – HeartBeatRequest-129 . In response user will get message code 130 same
structure.
------------------------------------End of document--------------------------------