Graphing Finance Data

import urllib2

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.dates as mdates
import numpy as np

def grabQuandl(ticker):

    netIncomeAr = []
    revAr = []
    ROCAr = []
    endLink = 'sort_order=asc'

    endLink2 = 'sort_order=asc&auth_token=asdfasdfsagsvasd'
        urlAttempt = ''+ticker+'_NET_INC.csv?&'+endLink2
        print urlAttempt
        netIncome = urllib2.urlopen(''+ticker+'_NET_INC.csv?&'+endLink2).read()
        revenue = urllib2.urlopen(''+ticker+'_REV_LAST.csv?&'+endLink2).read()
        ROC = urllib2.urlopen(''+ticker+'_ROC.csv?&'+endLink2).read()

        splitNI = netIncome.split('\n')
        print 'Net Income:'
        for eachNI in splitNI[1:-1]:
            print eachNI
        print '___________'
        splitRev = revenue.split('\n')
        print 'Revenue:'
        for eachRev in splitRev[1:-1]:
            print eachRev
        print '___________'
        splitROC = ROC.split('\n')
        print 'Return on Capital:'
        for eachROC in splitROC[1:-1]:
            print eachROC

        incomeDate, income = np.loadtxt(netIncomeAr, delimiter=',', unpack=True,
                                        converters={ 0: mdates.strpdate2num('%Y-%m-%d')})

        fig = plt.figure()
        ax1 = plt.subplot2grid((6,4), (0,0), rowspan=6, colspan=4)

    except Exception, e:
        print 'failed the main quandl loop for reason of',str(e)


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