Module Expr Str Import alias identifier Import alias identifier Import alias identifier Import alias identifier Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore ListLoad Str Str Str Str Str Str Str Str Str Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Expr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad Print Str Call NameLoad SubscriptLoad NameLoad Slice Expr Str Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr attr Call AttributeLoad NameLoad attr Num Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpSub AttributeLoad NameLoad attr Num Assign NameStore ListLoad NameLoad While CompareNotEq SubscriptLoad NameLoad Index Num NameLoad body Expr Call AttributeLoad NameLoad attr BinOpAdd SubscriptLoad NameLoad Index Num Call AttributeLoad NameLoad attr keyword Num Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Expr Str Assign NameStore BinOpMult ListLoad Num Call NameLoad NameLoad Assign NameStore BinOpMult ListLoad Num Call NameLoad NameLoad For NameStore Call NameLoad Call NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Str Expr Str For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body Expr Str If Call NameLoad SubscriptLoad NameLoad Index NameLoad body Continue Expr Str For NameStore Call NameLoad Call NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad BinOpAdd SubscriptLoad NameLoad Index NameLoad Num If UnaryOpNot Call NameLoad SubscriptLoad AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Index TupleLoad NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad BinOpAdd SubscriptLoad NameLoad Index NameLoad Num Expr Str Assign NameStore ListLoad Assign NameStore Num Assign NameStore Num For TupleStore NameStore NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr TupleLoad BinOpDiv BinOpMult SubscriptLoad NameLoad Index NameLoad Num SubscriptLoad NameLoad Index NameLoad NameLoad If UnaryOpNot CompareEq SubscriptLoad NameLoad Index NameLoad Num body Assign NameStore BinOpAdd NameLoad Num If CompareEq SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad body Assign NameStore BinOpAdd NameLoad Num Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr For NameStore NameLoad body Print BinOpMod Str TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Print BinOpMod Str TupleLoad NameLoad Call NameLoad NameLoad Print BinOpMod Str TupleLoad NameLoad Call NameLoad NameLoad Expr Str Assign NameStore NameStore SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Str Assign NameStore AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr For TupleStore NameStore NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad SubscriptLoad NameLoad ExtSlice Slice Index NameLoad Expr Call AttributeLoad Call AttributeLoad NameLoad attr attr keyword Num Expr Call AttributeLoad NameLoad attr NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str Expr Call NameLoad Str keyword Str
N/A N/A 
(c) 2011, 2012 Georgia Tech Research Corporation
This source code is released under the New BSD license.  Please see
http://wiki.quantsoftware.org/index.php?title=QSTK_License
for license details.

Created on June 1, 2011

@author: John Cornwell
@contact: JohnWCornwellV@gmail.com
@summary: Demonstrates the retrieval and use of Compustat data from the DataAccess object.
 N/A qstkutil.qsdateutil du N/A qstkutil.tsutil tsu N/A qstkutil.DataAccess da N/A datetime dt N/A matplotlib.pyplot plt pylab * math isnan copy copy N/A symbols N/A GE MSFT XOM PFE C WMT INTC AAPL GOOG N/A  Create compustat object and query it for some information  N/A compustatObj N/A N/A da DataAccess Compustat N/A N/A N/A compustatObj get_info N/A  Get data items and create dictionary to translate between string and index  N/A lsItems N/A N/A compustatObj get_data_labels N/A dLabel N/A dict N/A zip lsItems N/A range N/A len lsItems N/A Valid data items (sorted):
 N/A sort N/A lsItems N/A N/A  Create timestamps for 5 year period, must include all days, financial report may have been filed on non-NYSE day  N/A  get todays date, time = 16:00:00  N/A dtEnd N/A N/A N/A dt datetime combine N/A N/A N/A N/A N/A dt datetime now date N/A N/A dt time 16 N/A dtStart N/A N/A dtEnd replace year N/A N/A dtEnd year 5 N/A tsAll N/A dtStart N/A N/A N/A tsAll N/A -1 dtEnd N/A N/A N/A N/A tsAll append N/A N/A tsAll N/A -1 N/A N/A dt timedelta days 1 N/A  Query data object  N/A dmValues N/A N/A compustatObj get_data tsAll symbols lsItems N/A  Keep track of non-nan data entries  N/A llTotal N/A N/A 0 N/A len lsItems N/A llValid N/A N/A 0 N/A len lsItems N/A lStock N/A range N/A len symbols N/A N/A dmKeys N/A dmValues N/A N/A dLabel N/A gvkey N/A  Loop through all time indexes  N/A N/A i row N/A enumerate N/A dmKeys values N/A N/A  Check nan gvkey value, indicating an invalid entry row skip  N/A N/A isnan N/A row N/A lStock N/A N/A N/A  check for other valid entries in the other data types  N/A lInd N/A range N/A len lsItems N/A N/A N/A llTotal N/A lInd N/A N/A llTotal N/A lInd 1 N/A N/A N/A isnan N/A N/A N/A dmValues N/A lInd values N/A N/A i lStock N/A N/A N/A llValid N/A lInd N/A N/A llValid N/A lInd 1 N/A  sort and print results by percentage valid data  N/A ltBoth N/A N/A lNonZero 0 N/A lHundred 0 N/A N/A i sLabel N/A enumerate lsItems N/A N/A N/A N/A ltBoth append N/A N/A N/A N/A llValid N/A i 100.0 N/A llTotal N/A i sLabel N/A N/A N/A N/A llValid N/A i 0 N/A N/A lNonZero N/A lNonZero 1 N/A N/A N/A llValid N/A i N/A llTotal N/A i N/A N/A lHundred N/A lHundred 1 N/A N/A N/A ltBoth sort N/A N/A N/A ltBoth reverse N/A tRes ltBoth N/A N/A N/A %10s: %.02lf%% N/A N/A tRes N/A 1 N/A tRes N/A 0 N/A N/A 
%i out of %i elemenets non-zero. N/A lNonZero N/A len lsItems N/A N/A %i out of %i elemenets have 100%% participation. N/A lHundred N/A len lsItems N/A  Retrieve and plot quarterly earnings per share  N/A dmEps dmKeys N/A dmValues N/A N/A dLabel N/A EPSPIQ N/A naEps N/A dmEps values N/A N/A N/A tsu fillforward naEps N/A N/A N/A plt clf N/A N/A i sStock N/A enumerate symbols N/A N/A N/A N/A plt plot tsAll N/A naEps N/A N/A N/A i N/A N/A N/A N/A N/A plt gcf autofmt_xdate rotation 45 N/A N/A N/A plt legend symbols loc upper left N/A N/A N/A plt title EPS of various stocks N/A N/A savefig tutorial6.pdf format pdf