Module Expr Str ImportFrom alias alias alias FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr Call NameLoad Str Assign AttributeStore NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam defaults body AugAssignAdd AttributeStore NameLoad attr Num If CompareLt AttributeLoad NameLoad attr Num body Return Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Str Num Str attr Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Str Num Str attr If CompareGt NameLoad NameLoad body Expr Call NameLoad AttributeLoad NameLoad attr Num orelse If CompareLt NameLoad NameLoad body Expr Call NameLoad AttributeLoad NameLoad attr Num Expr Call NameLoad keyword Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Str keyword NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad NameLoad body Import alias identifier Import alias Expr Call AttributeLoad Call AttributeLoad NameLoad attr attr Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr Str If BoolOpAnd CompareIn Str NameLoad CompareIn Str NameLoad CompareIn Str NameLoad body Expr Call AttributeLoad SubscriptLoad NameLoad Index Str attr keyword NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index ListLoad Str Str attr keyword NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index ListComp CompareNotEq NameLoad ListLoad comprehension NameStore AttributeLoad NameLoad attr Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index ListComp CompareGt SubscriptLoad SubscriptLoad NameLoad Index Num Index Str Num comprehension NameStore AttributeLoad NameLoad attr Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index ListComp CompareLt SubscriptLoad SubscriptLoad NameLoad Index Num Index Str Num comprehension NameStore AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index AttributeLoad NameLoad attr Str keyword Num keyword Str Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index AttributeLoad NameLoad attr Str keyword Num keyword Str Expr Call AttributeLoad NameLoad attr keyword Num orelse Assign NameStore Str Expr Call AttributeLoad NameLoad attr NameLoad keyword TupleLoad Num Num Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list If CompareEq NameLoad Str body ImportFrom alias Import alias ImportFrom alias ImportFrom alias Assign NameStore Call NameLoad Num Num Num Num Num Num Num AttributeLoad NameLoad attr Assign NameStore Call NameLoad Num Num Num Num Num Num Num AttributeLoad NameLoad attr Assign NameStore Call NameLoad keyword ListLoad Str keyword Dict keyword NameLoad keyword NameLoad Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad keyword NameLoad
N/A N/A Dual Moving Average Crossover algorithm.

This algorithm buys apple once its short moving average crosses
its long moving average (indicating upwards momentum) and sells
its shares once the averages cross again (indicating downwards
momentum).
 zipline.api order_target record symbol initialize N/A N/A context N/A N/A N/A N/A context sym N/A symbol AAPL N/A N/A context i 0 N/A handle_data N/A N/A context data N/A N/A N/A N/A context i 1 N/A N/A N/A context i 300 N/A N/A N/A short_mavg N/A N/A N/A N/A data history N/A context sym price 100 1d mean N/A long_mavg N/A N/A N/A N/A data history N/A context sym price 300 1d mean N/A N/A short_mavg long_mavg N/A N/A N/A order_target N/A context sym 100 N/A N/A N/A short_mavg long_mavg N/A N/A N/A order_target N/A context sym 0 N/A N/A record AAPL N/A N/A data current N/A context sym price short_mavg short_mavg long_mavg long_mavg N/A analyze N/A N/A context results N/A None None N/A N/A matplotlib.pyplot plt N/A logbook N/A N/A N/A N/A N/A logbook StderrHandler push_application N/A log N/A N/A logbook Logger Algorithm N/A fig N/A N/A plt figure N/A ax1 N/A N/A fig add_subplot 211 N/A N/A N/A N/A results portfolio_value plot ax ax1 N/A N/A N/A ax1 set_ylabel Portfolio value (USD) N/A ax2 N/A N/A fig add_subplot 212 N/A N/A N/A ax2 set_ylabel Price (USD) N/A N/A N/A AAPL results N/A short_mavg results N/A long_mavg results N/A N/A N/A N/A N/A results N/A AAPL plot ax ax2 N/A N/A N/A N/A results N/A N/A short_mavg long_mavg plot ax ax2 N/A trans N/A N/A results ix N/A N/A N/A t N/A N/A t N/A results transactions N/A buys N/A N/A trans ix N/A N/A N/A N/A N/A t N/A 0 N/A amount 0 N/A t N/A trans transactions N/A sells N/A N/A trans ix N/A N/A N/A N/A N/A t N/A 0 N/A amount 0 N/A t N/A trans transactions N/A N/A N/A ax2 plot N/A buys index N/A N/A N/A results short_mavg ix N/A N/A buys index ^ markersize 10 color m N/A N/A N/A ax2 plot N/A sells index N/A N/A N/A results short_mavg ix N/A N/A sells index v markersize 10 color k N/A N/A N/A plt legend loc 0 N/A N/A msg AAPL, short_mavg & long_mavg data not captured using record(). N/A N/A N/A ax2 annotate msg xy N/A 0.1 0.5 N/A N/A N/A log info msg N/A N/A N/A plt show N/A N/A N/A __name__ __main__ N/A datetime datetime N/A pytz zipline.algorithm TradingAlgorithm zipline.utils.factory load_bars_from_yahoo N/A start N/A datetime 2011 1 1 0 0 0 0 N/A pytz utc N/A end N/A datetime 2013 1 1 0 0 0 0 N/A pytz utc N/A data N/A load_bars_from_yahoo stocks N/A AAPL indexes N/A start start end end N/A algo N/A TradingAlgorithm initialize initialize handle_data handle_data N/A results N/A N/A algo run data N/A N/A analyze results results