Here's a quickie algo that does a daily re-allocation of S&P 500 sector ETF's (http://www.sectorspdr.com/sectorspdr/) based on a z-score comparison.
A couple notes:
# for development, turn off commissions & slippage
set_commission(commission.PerTrade(cost=0.0))
set_slippage(slippage.FixedSlippage(spread=0.00))
Also, note that orders are submitted at the close (and if the market closes early, no orders are submitted). This is inconsistent with the current Quantopian/IB practice of cancelling all orders at the end of the day. So, for live trading, the algo would need to be re-jiggered.
Grant