, , , ,

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 http://query.yahooapis.com/v1/public/yql 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="https://query.yahooapis.com/v1/public/yql">
		<asp:Parameter Name="q" DefaultValue="select * from yahoo.finance.quotes where symbol in  (&quot;YHOO&quot;,&quot;AAPL&quot;,&quot;GOOG&quot;,&quot;MSFT&quot;)"/>
		<asp:Parameter Name="env" DefaultValue="http://datatables.org/alltables.env"/>

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.