Connecting with Quandl for Annual Earnings Data



Hello everybody and welcome to the 11th fundamental investing with programming tutorial.

Now I want to talk about Quandl.com, which offers free financial data, which is absolutely awesome, this kind of financial data should be totally free, and easily accessible by programming.

Quandl offers an API and also modules in most major programming languages, that said, it looks like the module's main use would be if you were building a web app. In our case, we're not and we'd be looking for a very small and specific set of companies.

The Quandl API restricts anonymous calls to 50 a day, measured in UTC time. If you just make an account, that raises to 500 calls a day. Then, if you want more, you just have to contact them, and they, at least for now, assert that they will accept the request, they just want to know who is doing it. If you do want to exceed those 500 calls a day, you just need the api token, and you get that immediately when you make an account.

Anyway, to the tutorial!

import time
import urllib2
from urllib2 import urlopen


def grabQuandl(ticker):
    endLink = 'sort_order=asc'

    try:
        #Keep in mind this will result in 3 requests# ... so dont run the heck out of this.
        netIncome = urllib2.urlopen('http://www.quandl.com/api/v1/datasets/OFDP/DMDRN_'+ticker+'_NET_INC.csv?&'+endLink).read()
        revenue = urllib2.urlopen('http://www.quandl.com/api/v1/datasets/OFDP/DMDRN_'+ticker+'_REV_LAST.csv?&'+endLink).read()
        ROC = urllib2.urlopen('http://www.quandl.com/api/v1/datasets/OFDP/DMDRN_'+ticker+'_ROC.csv?&'+endLink).read()

        print netIncome
        print '__________________'
        print revenue
        print '__________________'
        print ROC
        print '__________________'
        
    except Exception,e:
        print 'failed in the main loop',str(e)
        pass

grabQuandl('YHOO')
		

The next tutorial:





  • Programming for Fundamental Investing
  • Getting Company Data
  • Price to Book ratio example
  • Python Stock Screener for Price to Book
  • Python Screener for PEG Ratio
  • Adding Price to Earnings
  • Getting all Russell 3000 stock tickers
  • Getting all Russell 3000 stock tickers part 2
  • More stock Screening
  • Completing Basic Stock Screener
  • Connecting with Quandl for Annual Earnings Data
  • Organizing Earnings Data
  • Graphing Finance Data
  • Finishing the Graphing
  • Adding the Graphing to the Screener
  • Preparing figure to Accept Finance Data
  • Adding Historical Earnings to Stock Screener Chart Data
  • Completing the Fundamental Investing Stock Screeners