Thanks Grant and Brent. I had clones a Mebane Farber code modified it (see below under Code:). It worked fine with the original equities that were used. I was trying to compare this code to other code in another system so I changed the equities to make the ones being used in the other system. That's when I ran into the error below
ERROR:
NoTradeDataAvailable: {"symbol":"EEM","property":"mavg","algo_time":1371600000000,"first_traded":1010681460000,"sid":17845}
File test_algorithm_sycheck.py:24, in handle_data
File test_algorithm_sycheck.py:24, in
File algoproxy.py:1032, in _transform
File algoproxy.py:1133, in transform
CODE:
EEM VNQ VEA DBC VTI BND
def initialize(context):
context.secs = [sid(17845),sid(26669),sid(34385),sid(28054),sid(22739),sid(33652)]
set_commission(commission.PerTrade(cost=7.95))
leverage = 1.0
context.weight = leverage/len(context.secs)
def reweight(context,data,wt,min_pct_diff=0.1):
liquidity = context.portfolio.positions_value+context.portfolio.cash
orders = {}
pct_diff = 0
for sec in wt.keys():
target = liquidity*wt[sec]/data[sec].price
current = context.portfolio.positions[sec].amount
orders[sec] = target-current
pct_diff += abs(orders[sec]*data[sec].price/liquidity)
if pct_diff > min_pct_diff:
#log.info(("%s ordering %d" % (sec, target-current)))
for sec in orders.keys(): order(sec, orders[sec])
def handle_data(context, data):
wt = dict(((sec,(data[sec].mavg(20)>data[sec].mavg(200))*context.weight) for sec in context.secs))
reweight(context,data,wt)