Click here to Skip to main content
13,152,181 members (37,625 online)
Click here to Skip to main content
Add your own
alternative version


17 bookmarked
Posted 19 Aug 2014

Free Up To Date Historical Stock Data

, 19 Aug 2014
Rate this:
Please Sign up or sign in to vote.
How to download historical raw stock data for each symbol traded at nasdaq and nyse.


There are many people out there who happily take your money for historical stock data. There are alternatives: The Yahoo API and Google trade API. What if you dont want to learn how to use them?

Simple: Nasdaq has a list of all traded symbols and yahoo financial api has an interface to download them.

If you just need the raw historical data for analysis with excel or your own software feel free to download the software. It will download to C:\Datenbank


In the financial sector a company is not listed by it's name but rather by its symbol. Microsoft Corp. would be MSFT and so on. Every tradable company has a uniqe Symbol (3 to 5 letter name)

The basis for this project is one link:

This link returns a list of all symbols ever traded in the US with some extra information. Now we can extract this information to a list with of type header:

struct header
            public string symbol;
            public string name;
            public string sector;
            public string industry;
            public string infolink;

These names are selfexplanatory with infolink being a link to the company website. What now?

Yahoo has a special link to download all raw historical data in one link:   REPLACE MSFT WITH SYMBOL

Very handy.

The Target

Our target is an app which can download all stock data to a folder on the harddisk called Database. It will contain every single symbol with all stock data availible for it and some extra information:

Example symbol: Database\AEPI


AEP Industries Inc.
Specialty Chemicals
Capital Goods



Beware: Everything will take about 900 MB of space. This is a standalone downloader so if we want to read from the file we would use something like this:


string[] subs=words[n].Split(",");

DateTime temp = DateTime.ParseExact(subs[0], "yyyyMMdd", null);

The first step would be to download all symbols:

//Get nyse and nasdaq symbols
System.Net.ServicePointManager.DefaultConnectionLimit = 100; //agressive downloading

string get_symbols()
            string contents = null;
                contents += GetWebPageContent("");
                contents += GetWebPageContent("");
            return contents;

GetWebPageContent downloads a website as a string. (For the exact implementation download the source project)

Now we have a list of strings which we can cast to a list of our header struct.

To recieve all data of a single symbol all we have to do is call the following line for each header:

string symbol=header.symbol;
contents = GetWebPageContent("" + symbol.ToUpperInvariant());

For better performance we start many downloads parallel:

List<header> headers = new List<header>(); //... all symbols are in this list

Parallel.For(0, length, new ParallelOptions { MaxDegreeOfParallelism = 100 }, i =>
     //download symbol data
     Thread todo = new Thread(unused => load_symbol(headers[i].symbol, k, lenght, start)); 
     //write header
     Thread todo2 = new Thread(unused2 => write_infos(headers[i]));     

     todo.IsBackground = true;
     todo2.IsBackground = true;



We write everything to the right folder and files in the two functions and thus the core of the app is finished.

What remains is the use of this data. We can use excel or own software. The target was some easy to use files on the harddrive and we achieved that. Individual files may contain every single day back to 1960.

Notice: If you use the close data, use the "Adj Close" column as this shows the adjusted price for any corporate actions such as stock splits, buybacks etc.

Have fun.

Things Left Undone

  • Command line arguments for form free downloading
  • Installer and background service which automatically updates the database every day
  • Download singe symbols and automatically look up symbol of company name
  • Proxy support

If you have implemented or really need any of these features or have some ideas please leave a comment.


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

D. Infuehr
Austria Austria
Currently i am 21 years old. I started making software when I was 13.
I use my spare time to make C# and C++ applications.

You may also be interested in...


Comments and Discussions

Generalvery good Pin
Southmountain13-Dec-15 5:15
memberSouthmountain13-Dec-15 5:15 
QuestionBe careful which close price you use Pin
Duncan Edwards Jones19-Aug-14 22:22
professionalDuncan Edwards Jones19-Aug-14 22:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170924.2 | Last Updated 20 Aug 2014
Article Copyright 2014 by D. Infuehr
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid