Question #45617

hey i want to have google's stock value as it updates in a c# console application how can i do this.

Expert's answer

Here is the processed document with the code fragment restored and formatted:

Answer on Question #45617, Programming, C#

Problem.

hey i want to have google's stock value as it updates in a c# console application how can i do this.

Solution.

You may use Yahoo Finance API. The url

http://download.finance.yahoo.com/d/quotes.csv?s=GOOG&f=sabd1t1

will return information in the csv table.

- http://quote.yahoo.com/d/quotes.csv? - the default URL to get the information;

- 's=' - stock symbols separated by "+";

- & - to join the string;

- 'f=' - special tags.

Tags provided by Yahoo! Finance:



I included a simple example.

Code


using System;
using System.Net;
class Program
{
    static void Main(string[] args)
    {
        // Dowload information (Yahoo Finance API)
        WebClient client = new WebClient();
        string downloadString =
        client.DownloadString("http://download.finance.yahoo.com/d/quotes.csv?s=GOOG&f=sabd1t1");
        // String output
        string[] split = downloadString.Split(new Char[] {','});
        foreach (string s in split)
        {
            Console.WriteLine(s);
        }
    }
}


Result

```

'G00G'

284.95

284.80

9/5/2014"

$2:18pm"

```

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS