Manage Learn to apply best practices and optimize your operations.

Agent to retrieve NASDAQ stock quote

These two agents will take your own companies stock symbol and return a bunch of cool informatiion.

This is two tips for the price of one. These two agents will take your own company's stock symbol and return a bunch of cool informatiion. It will also show you a little about parsing XML. NOTE: this is only for use by companies listed on NASDAQ.

Tip one gives just the quote and change percentage.

 Sub Initialize Dim xmlapp As Variant Dim sourceFile As Variant Dim price As Variant Dim Change As Variant 'The sourceFile variable must be returned as XML sourceFile="http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=IBM" 'This line creates the Microsoft.XMLDOM object (parser). Set xmlapp = CreateObject("Microsoft.XMLDOM") xmlapp.async = False 'This line loads the XML into the parser. xmlapp.load(sourceFile) ' Get the value of the tags. price=ElementsByTagName(xmlapp,"last-sale-price") Dim s As New notessession Dim doc As notesdocument Set doc=s.documentcontext Doc.Quote=price 'Do not save document as is is for display on the web only End Sub Function ElementsByTagName(xmlapp,Tag As String)As Variant Dim XMLList() As String Dim x As Variant Dim i As Integer Set x=xmlapp.getElementsByTagName(Tag) Redim XMLList(1 To x.length) For i = 1 To x.length XMLList(i)=(x.item(i-1).text) Next ElementsByTagName=XMLList End Function End of tip one

Tip two gives you a lot more information on the quote.

 Sub initialize Dim s As New notessession Dim xmlapp As Variant Dim sourceFile As Variant Dim doc As notesdocument ''The sourceFile variable must be returned as XML sourceFile="http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol="IBM" 'This line creates the Microsoft.XMLDOM object(parser). Set xmlapp = CreateObject("Microsoft.XMLDOM") xmlapp.async = False 'This line loads the XML into the parser. xmlapp.load(sourceFile) 'This sets up the variables for the xml tag values Dim LastSale As Variant Dim Volume As Variant Dim Change As Variant Dim ChangePercent As Variant Dim DayHigh As Variant Dim high52 As Variant Dim DayLow As Variant Dim low52 As Variant Dim Bid As Variant Dim EPS As Variant Dim Ask As Variant Dim PERatio As Variant Dim Dividend As Variant Dim Sharesout As Variant Dim POpen As Variant Dim PrevClose As Variant Dim LastSize As Variant ' Get the value of the tags LastSale=ElementsByTagName(xmlapp,"last-sale-price") Volume=ElementsByTagName(xmlapp,"share-volume-qty") Change=ElementsByTagName(xmlapp,"net-change-price") ChangePercent=ElementsByTagName(xmlapp,"net-change-pct") DayHigh=ElementsByTagName(xmlapp,"todays-high-price") high52=ElementsByTagName(xmlapp,"fifty-two-wk-high-price") DayLow=ElementsByTagName(xmlapp,"todays-low-price") low52=ElementsByTagName(xmlapp,"fifty-two-wk-low-price") Bid=ElementsByTagName(xmlapp,"best-bid-price") EPS=ElementsByTagName(xmlapp,"earnings-actual-eps-amt") Ask=ElementsByTagName(xmlapp,"best-ask-price") PERatio=ElementsByTagName(xmlapp,"current-pe-ratio") Dividend=ElementsByTagName(xmlapp,"cash-dividend-amt") Sharesout=ElementsByTagName(xmlapp,"total-outstanding-shares-qty") 'POpen=ElementsByTagName(xmlapp,"") PrevClose=ElementsByTagName(xmlapp,"previous-close-price") 'LastSize=ElementsByTagName(xmlapp,"") 'Set the document to display doc.LastSale=LastSale doc.Volume=Volume doc.Change=Change doc.ChangePercent=ChangePercent doc.DayHigh=DayHigh doc.high52=high52 doc.DayLow=DayLow doc.low52= low52 doc.Bid=Bid doc.Bid=Doc.Bid(0) doc.EPS=EPS doc.Ask=Ask doc.Ask=doc.Ask(0) doc.PERatio=PERatio doc.Dividend=Dividend doc.Sharesout=Sharesout 'doc.POpen=POpen doc.PrevClose=PrevClose 'doc.LastSize=LastSize doc.Chge=Change doc.Price=LastSale 'Do not save document as is is for display on the web only End Sub Function ElementsByTagName(xmlapp,Tag As String)As Variant Dim XMLList() As String Dim x As Variant Dim i As Integer Set x=xmlapp.getElementsByTagName(Tag) Redim XMLList(1 To x.length) For i = 1 To x.length XMLList(i)=(x.item(i-1).text) Next ElementsByTagName=XMLList End Function

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close