The problem is that when iterating over the portfolio, I get position objects back, instead of equity objects, and I can't sell position objects!
#iterate over all currently held positions
for sec in context.portfolio.positions:
#check each security to see if we want to keep it
if sec not in context.secs_to_keep:
#if we don't want to keep it, sell it
order_target_percent(sec,0)