You need to sign in to do that
Don't have an account?
baller4life7
STOCK market information for accounts
Hi guys,
I was wondering what would be the best solution to provide stock quotes and charts for an account on its detail page...
Do you already have solutions for that?
<apex:page controller="GetStockController">
<apex:form >
<apex:pageblock >
<apex:pageblockSection >
Stock Code <apex:inputtext value="{!stockCode}" />
<apex:commandButton value="Get Value" action="{!getStockValue}"/>
<apex:outputlabel value="{!stockValue}"></apex:outputlabel>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
public class GetStockController {
public string stockCode{get;set;}
public string stockValue {get;set;}
public void getStockValue(){
StockQuoteClient.StockQuoteSoap client = new StockQuoteClient.StockQuoteSoap();
String retValue = client.GetQuote(stockCode);
system.debug('val = '+retValue);
XMLDom parser = new XMLDom(retValue);
stockValue = parser.getElementByTagName('Name').textContent()+' : ' +parser.getElementByTagName('Last').textContent(); }
}
Tag Names has been extracted from the document below. You can use the tagnames as u wish and depends on the information you would like to put up on your page.
http://www.webservicex.net/stockquote.asmx/GetQuote
This XML file does not appear to have any style information associated with it. The document tree is shown below.<string xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>GOOG</Symbol><Last>534.18</Last><Date>9/7/2011</Date><Time>3:35pm</Time><Change>+12.00</Change><Open>529.97</Open><High>535.939</High><Low>527.40</Low><Volume>2072544</Volume><MktCap>172.5B</MktCap><PreviousClose>522.18</PreviousClose><PercentageChange>+2.30%</PercentageChange><AnnRange>463.02 - 642.96</AnnRange><Earns>27.719</Earns><P-E>18.84</P-E><Name>Google Inc.</Name></Stock></StockQuotes></string>
Hope this helps..
truly NCC
All Answers
As per my knowledge,
You need to call up a webservice for that, and then include few custom fields in the account page to display the company relevant stock information.
regards Naveen
Thank you newcloudcoder!
Which webservices do you know? Are they free?
I knew of webservicex.net. If you browse their website, you do find their services for free.. u can find the link to their WSDL file. Use that to call their webservice. Hope you know the procedures. go to www.webservicex.net
regards
NCC
Thanks for the link!
I generated the following class:
However I have no clue how to use it ... How can I get the stock quotes in a visualforce page now?
<apex:page controller="GetStockController">
<apex:form >
<apex:pageblock >
<apex:pageblockSection >
Stock Code <apex:inputtext value="{!stockCode}" />
<apex:commandButton value="Get Value" action="{!getStockValue}"/>
<apex:outputlabel value="{!stockValue}"></apex:outputlabel>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
public class GetStockController {
public string stockCode{get;set;}
public string stockValue {get;set;}
public void getStockValue(){
StockQuoteClient.StockQuoteSoap client = new StockQuoteClient.StockQuoteSoap();
String retValue = client.GetQuote(stockCode);
system.debug('val = '+retValue);
XMLDom parser = new XMLDom(retValue);
stockValue = parser.getElementByTagName('Name').textContent()+' : ' +parser.getElementByTagName('Last').textContent(); }
}
Tag Names has been extracted from the document below. You can use the tagnames as u wish and depends on the information you would like to put up on your page.
http://www.webservicex.net/stockquote.asmx/GetQuote
This XML file does not appear to have any style information associated with it. The document tree is shown below.<string xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>GOOG</Symbol><Last>534.18</Last><Date>9/7/2011</Date><Time>3:35pm</Time><Change>+12.00</Change><Open>529.97</Open><High>535.939</High><Low>527.40</Low><Volume>2072544</Volume><MktCap>172.5B</MktCap><PreviousClose>522.18</PreviousClose><PercentageChange>+2.30%</PercentageChange><AnnRange>463.02 - 642.96</AnnRange><Earns>27.719</Earns><P-E>18.84</P-E><Name>Google Inc.</Name></Stock></StockQuotes></string>
Hope this helps..
truly NCC
If you add the XMLDom class and http://www.webservicex.net/stockquote.asmx to the remote sites, it works perfect! Thank you very much!
Yeah..Sorry for skipping that step..It was out of my mind.. Anyways I'm happy.