---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-29-549744c676a3> in <module>()
26
27 # Run algorithm
---> 28 perf_manual = algo_obj.run(data)
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\algorithm.pyc in run(self, source, overwrite_sim_params, benchmark_return_source)
515 # perf dictionary
516 perfs = []
--> 517 for perf in self.gen:
518 perfs.append(perf)
519
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\gens\tradesimulation.pyc in transform(self, stream_in)
110 date,
111 snapshot,
--> 112 self.algo.instant_fill,
113 )
114 # Perf messages are only emitted if the snapshot contained
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\gens\tradesimulation.pyc in _process_snapshot(self, dt, snapshot, instant_fill)
304
305 if any_trade_occurred:
--> 306 new_orders = self._call_handle_data()
307 for order in new_orders:
308 perf_process_order(order)
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\gens\tradesimulation.pyc in _call_handle_data(self)
333 self.algo,
334 self.current_data,
--> 335 self.simulation_dt,
336 )
337 orders = self.algo.blotter.new_orders
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\utils\events.pyc in handle_data(self, context, data, dt)
192 def handle_data(self, context, data, dt):
193 for event in self._events:
--> 194 event.handle_data(context, data, dt)
195
196
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\utils\events.pyc in handle_data(self, context, data, dt)
210 """
211 if self.rule.should_trigger(dt):
--> 212 self.callback(context, data)
213
214
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\algorithm.pyc in handle_data(self, data)
303 self.history_container.update(data, self.datetime)
304
--> 305 self._handle_data(self, data)
306
307 # Unlike trading controls which remain constant unless placing an
<ipython-input-29-549744c676a3> in handle_data(context, data)
15 def handle_data(context,data):
16 if context.count == 0:
---> 17 order_target_percent (context.stocks[0], 1)
18 context.count = 1
19 print (context.portfolio.positions)
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\utils\api_support.pyc in wrapped(*args, **kwargs)
49 def wrapped(*args, **kwargs):
50 # Get the instance and call the method
---> 51 return getattr(get_algo_instance(), f.__name__)(*args, **kwargs)
52 # Add functor to zipline.api
53 setattr(zipline.api, f.__name__, wrapped)
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\algorithm.pyc in order_target_percent(self, sid, target, limit_price, stop_price, style)
1002 limit_price=limit_price,
1003 stop_price=stop_price,
-> 1004 style=style)
1005
1006 @api_method
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\algorithm.pyc in order_target_value(self, sid, target, limit_price, stop_price, style)
980 is actually the target exposure, as Futures have no 'value'.
981 """
--> 982 target_amount = self._calculate_order_value_amount(sid, target)
983 return self.order_target(sid, target_amount,
984 limit_price=limit_price,
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\algorithm.pyc in _calculate_order_value_amount(self, asset, value)
679 asset being ordered.
680 """
--> 681 last_price = self.trading_client.current_data[asset].price
682
683 if tolerant_equals(last_price, 0):
g:\Anaconda3-32bit\envs\zipline2.7\lib\site-packages\zipline-0.8.0rc1-py2.7-win32.egg\zipline\protocol.pyc in __getitem__(self, name)
516
517 def __getitem__(self, name):
--> 518 return self._data[name]
519
520 def __delitem__(self, name):
KeyError: Equity(0, symbol='SPY', asset_name='', exchange='', start_date=None, end_date=None, first_traded=None)