Dear All,
I have linked NSE and BSE websites for pulling real time prices for the day.
However the extraction from both website is very slow (It takes 20 mins) , I want to speed up the process and reduce the timings to 1-2 minutes.
Kindly have a look on the below Coding and advise me on increasing the speed.
Thank you in advance for your help. Really appreciate your time and consideration.
Please find the <acronym title="visual basic for applications">VBA</acronym> codings below:-
Module 1 - BSE Webiste
Public Function getBSEData(ScriptCode As String)
URL = "http://www.bseindia.com/stock-share-price/SiteCache/EQHeaderData.aspx?text=" & ScriptCode
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", URL, False
xmlHttp.setRequestHeader "Content-Type", "text/JSON"
xmlHttp.send
Debug.Print xmlHttp.responseText
getBSEData = xmlHttp.responseText
'jsonString = xmlHttp.responseText
'Set sc = CreateObject("ScriptControl"): sc.Language = "JScript"
'Set jsonDecode = sc.Eval("(" + jsonString + ")")
'Debug.Print jsonDecode.Data(1).lastPrice
End Function
Public Function processData(inputInfo As String, wh As Integer)
Dim splitData() As String
splitData() = Split(inputInfo, ",")
Debug.Print UBound(splitData)
Debug.Print splitData(UBound(splitData) - wh + 1)
processData = splitData(UBound(splitData) - wh + 1)
End Function
Module 2 - Nse Website
Public Function getNSEData(scripID As String)
URL = "http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/ajaxGetQuoteJSON.jsp?symbol=" & scripID
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", URL, False
xmlHttp.setRequestHeader "Content-Type", "text/JSON"
xmlHttp.send
Debug.Print xmlHttp.responseText
getNSEData = xmlHttp.responseText
'jsonString = xmlHttp.responseText
'Set sc = CreateObject("ScriptControl"): sc.Language = "JScript"
'Set jsonDecode = sc.Eval("(" + jsonString + ")")
'Debug.Print jsonDecode.Data(1).lastPrice
End Function
I have linked NSE and BSE websites for pulling real time prices for the day.
However the extraction from both website is very slow (It takes 20 mins) , I want to speed up the process and reduce the timings to 1-2 minutes.
Kindly have a look on the below Coding and advise me on increasing the speed.
Thank you in advance for your help. Really appreciate your time and consideration.
Please find the <acronym title="visual basic for applications">VBA</acronym> codings below:-
Module 1 - BSE Webiste
Public Function getBSEData(ScriptCode As String)
URL = "http://www.bseindia.com/stock-share-price/SiteCache/EQHeaderData.aspx?text=" & ScriptCode
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", URL, False
xmlHttp.setRequestHeader "Content-Type", "text/JSON"
xmlHttp.send
Debug.Print xmlHttp.responseText
getBSEData = xmlHttp.responseText
'jsonString = xmlHttp.responseText
'Set sc = CreateObject("ScriptControl"): sc.Language = "JScript"
'Set jsonDecode = sc.Eval("(" + jsonString + ")")
'Debug.Print jsonDecode.Data(1).lastPrice
End Function
Public Function processData(inputInfo As String, wh As Integer)
Dim splitData() As String
splitData() = Split(inputInfo, ",")
Debug.Print UBound(splitData)
Debug.Print splitData(UBound(splitData) - wh + 1)
processData = splitData(UBound(splitData) - wh + 1)
End Function
Module 2 - Nse Website
Public Function getNSEData(scripID As String)
URL = "http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/ajaxGetQuoteJSON.jsp?symbol=" & scripID
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", URL, False
xmlHttp.setRequestHeader "Content-Type", "text/JSON"
xmlHttp.send
Debug.Print xmlHttp.responseText
getNSEData = xmlHttp.responseText
'jsonString = xmlHttp.responseText
'Set sc = CreateObject("ScriptControl"): sc.Language = "JScript"
'Set jsonDecode = sc.Eval("(" + jsonString + ")")
'Debug.Print jsonDecode.Data(1).lastPrice
End Function