KotakNet RTD |
One of the cool features of KotakNet is, it supports RTD server. Now you can get streaming real-time quotes in Excel.
RTD server gets data from Websocket, parses the received data and streams real time quotes to Excel.
The Syntax for Excel RTD Function is =RTD(ProgID,ServerName,Topic1,[Topic2])
ProgID: KotakNet.Rtd
ServerName: Blank
Topic1 - Ticker in the Format of [TRADESYMBOL].[EXCH] Ex: AXISBANK.NSE, NIFTY22FEB18FUT.NFO, SILVERM22FEB28FUT.MCX
Topic2 - Price Filed.
Supported Price Fields
"LAST", "PCTCHG", "NETCHG", "LASTSIZE", "BID", "BIDSIZE", "ASK", "ASKSIZE", "AVGPRICE", "VOLUME", "TOTALBUYQTY", "TOTALSELLQTY", "OPEN", "HIGH", "LOW", "CLOSE", "OI", "LTT", "LOWERCKT", "UPPERCKT", "MTM", "NETQTY", "AVGBOUGHTPRICE", "AVGSOLDPRICE", "BOUGHTQTY", "SOLDQTY", "PING"
Example:
=RTD("KotakNet.Rtd",,"AXISBANK.NSE","LAST")
=RTD("KotakNet.Rtd",,"AXISBANK.NSE","OPEN")
Adding RTD formula likes above in every cell is tedious, so we added a UDF "GetRTD" in the sample excel sheet, which will wrap the complex RTD function. User can use this UDF instead of the original RTD function, note this is not mandatory.
The syntax for the GetRTD is
=GetRTD(Exch, TrdSymbol, Field)
=GetRTD("NSE", "AXISBANK", "LAST") ‘ will get LTP
Public Function GetRTD(ByVal Exch As String, ByVal Trdsym As String, ByVal field As String) As Variant If (Exch = vbNullString Or Trdsym = vbNullString Or field = vbNullString) Then GetRTD = 0: Exit Function Exch = UCase(Exch) Trdsym = UCase(Trdsym) field = UCase(field) Dim Prfx As String Prfx = Trdsym & "." & Exch GetRTD = WorksheetFunction.RTD("KotakNet.Rtd", "", Prfx, field) End Function
Subscribe Quotes:
To get Real-time quotes in "Excel RTD", you must be logged-in to KotakNet and need to call the "SubscribeQuotes" method for the Symbol which you want data. This is equivalent to adding symbols in market watch of trading platform.
=SubscribeQuotes(Exch, TrdSymbol)
=SubscribeQuotes("NSE", "AXISBANK")
Changing RTD throttle interval:
By default, Excel will request real time data from RTD server at an interval of 2 seconds. Who wants to lag behind by 2 seconds in the stock markets where the prices are changing in micro seconds?
We will change the throttle interval to 0, so that Excel will update quotes in real time.
To Change RTD Interval:
In Excel, go to the Visual Basic Editor by pressing ALT+F11
Once you are in Visual Basic Editor, Press CTRL+G to open Immediate Window
Once you are in Immediate Window, Type the below command and Press enter
Application.RTD.ThrottleInterval = 0
To Check whether the interval is updated or not:
Type the below command in Immediate Window and Press enter
? Application.RTD.ThrottleInterval
The above command will return 0; if not 0 again set the interval as mentioned above
Most issues will be user or system specific
Common reasons for RTD issues
Excel not run with Admin rights
Firewall issues
Antivirus blocking and deleting files
Corrupt RTD Registry (Due to multiple install/uninstall of software’s that have RTD feature like NestTrader etc)
Corrupt Excel Registry (Due to Multiple versions installation of MS Office)
RTD Port is used by any other application
The below steps may resolve the RTD issue
Add KotakNet to your Antivirus Exclusion List
Enable Firewall for RTD port
Re-install KotakNet
Repair MS office
![]() |
---|
Do not download macro enabled excel files from untrusted sources. Macro enabled excel files are used to spread viruses and trojans. If need to download, then scan the downloaded file with your Anti virus |