

The first time the program runs these directories do not exist, so we must create them. We will save all the files to separate directories. Months are written indexed from zero: so 0 is January, 11 is December. We construct this url-address from variables inside the program, so that it changes for each value of the stock-ticker and the dates required (that were built in Step 1). Resolution of the data (daily, weekly, etc): Then, it needs a stock name (e.g.: Microsoft): Step 2: Downloading from Yahoo Finance APIįor downloading the CSV files with historical prices from Yahoo Finance’s API, we need the following URL structure: Read user input and download those stocks If blank, all SP500 Stocks will be downloaded") Pseudo code: Console.WriteLine("Enter stock names. If you have a different set of symbols you would like to download you should modify this file with your own stock-tickers.

The list of S&P500 stock-tickers is pulled from a CSV file in the program folder and was originally sourced from Wikipedia.

When the default parameters are used the program will download the entire S&P500 stock-tickers, from the date range of 1st January 2000 to 1st January 2014. The stock-tickers must be separated by a comma and listed on the yahoo finance website –. The program requests the user to enter the stock-tickers and date range they would like to download, or it will use its default values. Step 1: Building the stock names we want to download The code consists of two sections: first, we need to enter the stock names and date ranges we want to download, and then communicate with the Yahoo Finance’s API to download the requested files. Download C# Source Code for this Article Download
