Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1013011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:01:57+00:00 2026-05-16T10:01:57+00:00

I’m looking for an API that can be accessed via C# implementation where I

  • 0

I’m looking for an API that can be accessed via C# implementation where I can get access to free stock market historical information (index and individual companies).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:01:57+00:00Added an answer on May 16, 2026 at 10:01 am

    I have a couple of C# examples on my blog for getting historical data from Yahoo. It’s really simple…

    Update

    Regarding my example… I’m not saving the data to anything, I’m just printing in the console. You’d have to save the data in whatever format or data structure is most reasonable for you.

    // A dictionary with tags where the key is the tag
    // and the value is the description of the tag
    private Dictionary<string, string> _tags = new Dictionary<string, string>();
    
    private void DownloadData(String symbol)
    {
        string url = String.Format(
            "http://finance.yahoo.com/d/quotes.csv?s={0}&f=", symbol);
    
        //Get page showing the table with the chosen indices
        HttpWebRequest request = null;
        DFDataSet ds = new DFDataSet();
        Random rand = new Random(DateTime.Now.Millisecond);
        try
        {
            while (_running)
            {
                foreach (String key in _tags.Keys)
                {
                    lock (_sync)
                    {
                        request = (HttpWebRequest)WebRequest.CreateDefault(
                            new Uri(url + key));
                        request.Timeout = 30000;
    
                        using (var response = (HttpWebResponse)request.GetResponse())
                        using (StreamReader input = new StreamReader(
                            response.GetResponseStream()))
                        {
                            Console.WriteLine(String.Format("{0} {1} = {2}",
                                symbol, _tags[key], input.ReadLine());
                        }
                    }
                }
                Console.WriteLine(Thread.CurrentThread.Name + " running.");
                Thread.Sleep(60*1000); // 60 seconds
            }
        }
        catch (Exception exc)
        {
            Console.WriteLine(exc.Message);
        }
    }
    

    Note that you can request multiple tags in the same csv file, instead of one tag at a time… to do that, just string all the tags of interest together and add them to the URL just like you add a single tag. The values for the tags will be comma separated.

    Update 2.0

    Here is how you can get end of day (EOD) historical data from yahoo:

    void DownloadDataFromWeb(string symbol)
    {
        DateTime startDate = DateTime.Parse("1900-01-01");
    
        string baseURL = "http://ichart.finance.yahoo.com/table.csv?";
        string queryText = BuildHistoricalDataRequest(symbol, startDate, DateTime.Today);
        string url = string.Format("{0}{1}", baseURL, queryText);
    
        //Get page showing the table with the chosen indices
        HttpWebRequest request = null;
        HttpWebResponse response = null;
        StreamReader stReader = null;
    
        //csv content
        string docText = string.Empty;
        string csvLine = null;
        try
        {
            request = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
            request.Timeout = 300000;
    
            response = (HttpWebResponse)request.GetResponse();
    
            stReader = new StreamReader(response.GetResponseStream(), true);
    
            stReader.ReadLine();//skip the first (header row)
            while ((csvLine = stReader.ReadLine()) != null)
            {
                string[] sa = csvLine.Split(new char[] { ',' });
    
                DateTime date = DateTime.Parse(sa[0].Trim('"'));
                Double open =  double.Parse(sa[1]);
                Double high = double.Parse(sa[2]);
                Double low = double.Parse(sa[3]);
                Double close = double.Parse(sa[4]);
                Double volume = double.Parse(sa[5]);
                Double adjClose = double.Parse(sa[6]);
                // Process the data (e.g. insert into DB)
            }
        }
        catch (Exception e)
        {
            throw e;
        }
    }
    
    string BuildHistoricalDataRequest(string symbol, DateTime startDate, DateTime endDate)
    {
        // We're subtracting 1 from the month because yahoo
        // counts the months from 0 to 11 not from 1 to 12.
        StringBuilder request = new StringBuilder();
        request.AppendFormat("s={0}", symbol);
        request.AppendFormat("&a={0}", startDate.Month-1);
        request.AppendFormat("&b={0}", startDate.Day);
        request.AppendFormat("&c={0}", startDate.Year);
        request.AppendFormat("&d={0}", endDate.Month-1);
        request.AppendFormat("&e={0}", endDate.Day);
        request.AppendFormat("&f={0}", endDate.Year);
        request.AppendFormat("&g={0}", "d"); //daily
    
        return request.ToString();
    }
    

    The code above will go through each data instance in the CSV file, so you just need to save the data instances to arrays. Calculating the return should be straight forward from then on.

    // Create your data lists
    List<DateTime> date = new List<DateTime>();
    List<Double> open = new List<Double>();
    List<Double> high = new List<Double>();
    List<Double> low = new List<Double>();
    List<Double> close = new List<Double>();
    List<Double> volume = new List<Double>();
    List<Double> adjClose = new List<Double>();
    
    //
    // ...
    //
    
    // inside the DownloadDataFromWeb function:
    
    // Add the data points as you're going through the loop
    date.Add(DateTime.Parse(sa[0].Trim('"')));
    open.Add(double.Parse(sa[1]));
    high.Add(double.Parse(sa[2]));
    low.Add(double.Parse(sa[3]));
    close.Add(double.Parse(sa[4]));
    volume.Add(double.Parse(sa[5]));
    adjClose.Add(double.Parse(sa[6]));
    
    //
    // ...
    //
    
    // Calculate the return after you've downloaded all the data...
    

    I hope that’s helpful :).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For uses in Java API of design patterns, look at… May 16, 2026 at 11:21 am
  • Editorial Team
    Editorial Team added an answer A stack overflow normally means that your application will exit… May 16, 2026 at 11:21 am
  • Editorial Team
    Editorial Team added an answer Go to Start > Programs > Microsoft SQL Server >… May 16, 2026 at 11:21 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.