Stock market price data in SharePoint

Reading financial data, like stock market price for a company, is a task which can be very easy achieved in SharePoint. There are several ways you can do this. Very popular is JSONP way to read the data across domain, but I won’t write this time about it. I will write about how you can do this using a control special designed for this. And this is SharePoint:XmlUrlDataSource.

Let’s assume we are requested to display into a page stock market price for Apple, Microsoft and Google. A short search on the internet will reveal we can find this information at the following address. Yahoo provides an API for this at and is only a question of passing correct parameters to it. The good news is you do not need to write code for it as the control I am talking about can do everything for you.

<SharePoint:XmlUrlDataSource runat="server" XPath="query/results/quote" id="DSYahooSource" AuthType="None" HttpMethod="GET" selectcommand="">
		<asp:Parameter Name="q" DefaultValue="select * from where symbol in  (&quot;YHOO&quot;,&quot;AAPL&quot;,&quot;GOOG&quot;,&quot;MSFT&quot;)"/>
		<asp:Parameter Name="env" DefaultValue=""/>

Kindly note select parameters I have added and XPath. Select parameters will be automatically added to the API call and XPath will filter the XML obtained in order to display the data in a repeater.

From this point, everything is straight forward. Just place an asp:Repeater to your page, set data source to be the above one and set what information you want to display (I have used ask price as an example).

<asp:Repeater runat="server" DataSourceID="DSYahooSource">
    <ItemTemplate><%# DataBinder.Eval(Container.DataItem,"Ask")%></ItemTemplate>

If you want to do this on SharePoint:Online, very easy you can use a dataformwebpart with some XSLT, and you only need SharePoint Designer. If you want more complex solution, like something to deliver to a customer, which should look professional, go for a visual web part. Both choices are valid. The main idea is you do not need to look for solution outside the SharePoint, as it is already there.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s