<s> '''<STR_LIT>''' <EOL> import qstkutil . qsdateutil as du <EOL> import qstkutil . tsutil as tsu <EOL> import qstkutil . DataAccess as da <EOL> import datetime as dt <EOL> import matplotlib . pyplot as plt <EOL> from pylab import * <EOL> from math import isnan <EOL> from copy import copy <EOL> symbols = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:C>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> '''<STR_LIT>''' <EOL> compustatObj = da . DataAccess ( '<STR_LIT>' ) <EOL> compustatObj . get_info ( ) <EOL> '''<STR_LIT>''' <EOL> lsItems = compustatObj . get_data_labels ( ) <EOL> dLabel = dict ( zip ( lsItems , range ( len ( lsItems ) ) ) ) <EOL> print '<STR_LIT>' , sort ( lsItems [ : ] ) <EOL> '''<STR_LIT>''' <EOL> '''<STR_LIT>''' <EOL> dtEnd = dt . datetime . combine ( dt . datetime . now ( ) . date ( ) , dt . time ( <NUM_LIT:16> ) ) <EOL> dtStart = dtEnd . replace ( year = dtEnd . year - <NUM_LIT:5> ) <EOL> tsAll = [ dtStart ] <EOL> while ( tsAll [ - <NUM_LIT:1> ] != dtEnd ) : <EOL> tsAll . append ( tsAll [ - <NUM_LIT:1> ] + dt . timedelta ( days = <NUM_LIT:1> ) ) <EOL> '''<STR_LIT>''' <EOL> dmValues = compustatObj . get_data ( tsAll , symbols , lsItems ) <EOL> '''<STR_LIT>''' <EOL> llTotal = [ <NUM_LIT:0> ] * len ( lsItems ) <EOL> llValid = [ <NUM_LIT:0> ] * len ( lsItems ) <EOL> for lStock in range ( len ( symbols ) ) : <EOL> dmKeys = dmValues [ dLabel [ '<STR_LIT>' ] ] <EOL> '''<STR_LIT>''' <EOL> for i , row in enumerate ( dmKeys . values ) : <EOL> '''<STR_LIT>''' <EOL> if ( isnan ( row [ lStock ] ) ) : <EOL> continue <EOL> '''<STR_LIT>''' <EOL> for lInd in range ( len ( lsItems ) ) : <EOL> llTotal [ lInd ] = llTotal [ lInd ] + <NUM_LIT:1> <EOL> if ( not isnan ( dmValues [ lInd ] . values [ i , lStock ] ) ) : <EOL> llValid [ lInd ] = llValid [ lInd ] + <NUM_LIT:1> <EOL> '''<STR_LIT>''' <EOL> ltBoth = [ ] <EOL> lNonZero = <NUM_LIT:0> <EOL> lHundred = <NUM_LIT:0> <EOL> for i , sLabel in enumerate ( lsItems ) : <EOL> ltBoth . append ( ( ( llValid [ i ] * <NUM_LIT> / llTotal [ i ] ) , sLabel ) ) <EOL> if not llValid [ i ] == <NUM_LIT:0> : <EOL> lNonZero = lNonZero + <NUM_LIT:1> <EOL> if llValid [ i ] == llTotal [ i ] : <EOL> lHundred = lHundred + <NUM_LIT:1> <EOL> ltBoth . sort ( ) <EOL> ltBoth . reverse ( ) <EOL> for tRes in ltBoth : <EOL> print '<STR_LIT>' % ( tRes [ <NUM_LIT:1> ] , tRes [ <NUM_LIT:0> ] ) <EOL> print '<STR_LIT>' % ( lNonZero , len ( lsItems ) ) <EOL> print '<STR_LIT>' % ( lHundred , len ( lsItems ) ) <EOL> '''<STR_LIT>''' <EOL> dmEps = dmKeys = dmValues [ dLabel [ '<STR_LIT>' ] ] <EOL> naEps = dmEps . values <EOL> tsu . fillforward ( naEps ) <EOL> plt . clf ( ) <EOL> for i , sStock in enumerate ( symbols ) : <EOL> plt . plot ( tsAll , naEps [ : , i ] ) <EOL> plt . gcf ( ) . autofmt_xdate ( rotation = <NUM_LIT> ) <EOL> plt . legend ( symbols , loc = '<STR_LIT>' ) <EOL> plt . title ( '<STR_LIT>' ) <EOL> savefig ( '<STR_LIT>' , format = '<STR_LIT>' ) </s>
