Monday, April 29, 2013

Poor Boy's Data

Before we start collecting data we have to remember that a model is only as good as the data it uses but quality data comes with an expensive price tag and we don't have the cash to spare. For our purposes Yahoo! Finance will have to suffice.


Code


Language: Python 2.7
3rd Party Packages: None

This program is pretty simple to use, all we have to do is run the program and wait for it to terminate. Our data comes from Yahoo! so depending on the internet connection and the amount of data being downloaded this may take a few minutes to complete.

FileSnack link:  http://snk.to/f-c7clb99t

The zipped file contains:
  1. Main program: poorBoysData.py 
  2. S&P 500 companies: SP500.txt
  3. Empty folder: Tickers
To ensure the program runs properly keep the contents in the same location.  If we're saving to the desktop poorBoysData.py, SP500.txt, and Tickers all need to be on the desktop; if we're saving to the documents folder then poorBoysData.py, SP500.txt, and Tickers all need to be saved to the documents folder.


How the Code Works


Our Yahoo! Data Collector is pretty straight forward.  Our program navigates to Yahoo, downloads the historical data, and saves it to the file [stock's ticker].txt in the folder 'Tickers.'

In our back test we always ran into problems with 4:1 stock splits and special one-time dividends so to correct these data errors we replaced Yahoo!'s open, high, low, and close with the following:
Open = (Open / Close) * Adjusted Close
High= (High/ Close) * Adjusted Close
Low= (Low/ Close) * Adjusted Close
Close = Adjusted Close
The price adjustment can be turned off by setting adjustPrices to False.


Further Functionality and Modification


There are four primary variables that if changed will make the program perform a different function and collect data in a different way. We can choose to collect data from the S&P500 by changing isSP500 to True or we can collect a specific set of data by setting isUsersTickers to True and populating the usersTickerList list with ticker symbols.  The fourth is the adjustPrices variable mentioned above. 

1 comment:

  1. titanium app | TITanium Arts
    Our titanium rod in leg app is designed to titanium nitride coating service near me develop the fastest and the titanium plate flat irons fastest. Discover how to create it and make a titanium nail living. Get titanium earrings sensitive ears a free TITACORE APP

    ReplyDelete