Module Expr Str Import alias Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str Import alias Import alias Import alias Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Num FunctionDef arguments args defaults body Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr Str Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str If CompareGt Call NameLoad NameLoad Num body If CompareNotEq AttributeLoad SubscriptLoad Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Str Index Num attr Str body Continue If CompareNotEq AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Str body Continue If CompareNotEq AttributeLoad SubscriptLoad Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Str Index Num attr Str body Continue If CompareNotEq AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Str body Continue Assign NameStore NameLoad Break Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str For NameStore SubscriptLoad NameLoad Slice Num body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore AttributeLoad SubscriptLoad Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Str Index Num attr Assign NameStore AttributeLoad SubscriptLoad Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Str Index Num attr Assign NameStore AttributeLoad SubscriptLoad NameLoad Index NameLoad attr Assign NameStore AttributeLoad SubscriptLoad NameLoad Index NameLoad attr If CompareIs NameLoad NameLoad body Assign NameStore Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args defaults body TryExcept body Assign NameStore Call NameLoad Assign NameStore Call NameLoad NameLoad If CompareIs NameLoad NameLoad body Raise Call NameLoad Str Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A 
.. moduleauthor:: Gabriel Martin Becedillas Ruiz <gabriel.becedillas@gmail.com>
 N/A sys N/A N/A N/A N/A sys path append ../.. N/A pyalgotrade.logger N/A lxml.html N/A symbolsxml N/A logger N/A N/A N/A pyalgotrade logger getLogger get_sp500_symbols N/A TICKER_SYMBOL_COL 0 N/A COMPANY_COL 1 N/A GICS_COL 3 N/A GICS_SUB_INDUSTRY_COL 4 get_html N/A N/A N/A N/A N/A N/A N/A logger info Getting S&P 500 Component Stocks from Wikipedia N/A ret N/A N/A N/A lxml html parse http://en.wikipedia.org/wiki/List_of_S%26P_500_companies N/A ret N/A find_table N/A N/A htmlTree N/A N/A N/A N/A N/A logger info Finding the right table N/A ret None N/A tables N/A N/A htmlTree xpath //table[@class='wikitable sortable'] N/A table tables N/A N/A headers N/A N/A table xpath tr[1]/th N/A N/A N/A len headers 5 N/A N/A N/A N/A N/A N/A N/A N/A headers N/A TICKER_SYMBOL_COL xpath a[1] N/A 0 text Ticker symbol N/A N/A N/A N/A N/A N/A headers N/A COMPANY_COL text Company N/A N/A N/A N/A N/A N/A N/A N/A N/A headers N/A GICS_COL xpath a[1] N/A 0 text GICS N/A N/A N/A N/A N/A N/A headers N/A GICS_SUB_INDUSTRY_COL text GICS Sub Industry N/A N/A N/A ret table N/A N/A ret N/A parse_results N/A N/A table N/A N/A N/A ret N/A N/A symbolsxml Writer N/A N/A N/A logger info Parsing table N/A rows N/A N/A table xpath tr N/A row N/A rows N/A 1 N/A N/A cols N/A N/A row xpath td N/A tickerSymbol N/A N/A N/A N/A N/A cols N/A TICKER_SYMBOL_COL xpath a[1] N/A 0 text N/A company N/A N/A N/A N/A N/A cols N/A COMPANY_COL xpath a[1] N/A 0 text N/A gics N/A N/A cols N/A GICS_COL text N/A gicsSubIndustry N/A N/A cols N/A GICS_SUB_INDUSTRY_COL text N/A N/A gicsSubIndustry None N/A N/A gicsSubIndustry N/A N/A N/A ret addStock tickerSymbol company gics gicsSubIndustry N/A ret N/A main N/A N/A N/A N/A N/A N/A N/A htmlTree N/A get_html N/A table N/A find_table htmlTree N/A N/A table None N/A N/A N/A Exception S&P 500 Component Stocks table not found N/A symbolsXML N/A parse_results table N/A N/A N/A logger info Writing sp500.xml N/A N/A N/A symbolsXML write sp500.xml N/A N/A N/A Exception N/A e N/A N/A N/A N/A logger error N/A str e N/A N/A N/A __name__ __main__ N/A N/A N/A main