How can I get share/stock prices for my website?

Posted by admin on December 31st, 2009 and filed under stock prices | 2 Comments »

I m doing a virtual stock trading project which requires me to get latest (or fairly recent / delayed) stock prices. I will be stimulating graphs using the prices etc. XML format would be prefered.

this works for me using asp.net

public string[] GetQuote(string symbol)
{
string strAll;

string[] strAllArray;

try
{
string fullpath=@"http://quote.yahoo.com/d/quotes.csv?s=" + symbol + "&f=snl1d1t1c1ohgv&e=.csv";
HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(fullpath);
HttpWebResponse webresp = (HttpWebResponse)webreq.GetResponse();
StreamReader strm = new StreamReader(webresp.GetResponseStream(),Encoding.ASCII);
strAll = strm.ReadLine();
strm.Close();

strAll = strAll.Replace( "\"", "" );
strAllArray = strAll.Split( new char[] {’,'} );

}
catch(Exception)
{
strAllArray = null;
}
return strAllArray;
}

2 Responses

  1. ralphd42 Says:

    this works for me using asp.net

    public string[] GetQuote(string symbol)
    {
    string strAll;

    string[] strAllArray;

    try
    {
    string fullpath=@"http://quote.yahoo.com/d/quotes.csv?s=" + symbol + "&f=snl1d1t1c1ohgv&e=.csv";
    HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(fullpath);
    HttpWebResponse webresp = (HttpWebResponse)webreq.GetResponse();
    StreamReader strm = new StreamReader(webresp.GetResponseStream(),Encoding.ASCII);
    strAll = strm.ReadLine();
    strm.Close();

    strAll = strAll.Replace( "\"", "" );
    strAllArray = strAll.Split( new char[] {’,'} );

    }
    catch(Exception)
    {
    strAllArray = null;
    }
    return strAllArray;
    }
    References :

  2. terry m Says:

    give it to me
    References :

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.