Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Another way to rebalance - simple price and volume return
1 response

Thanks Anony,

Your TradeAtTheOpenSlippageModel thingy is slick. I gather that is allows one to basically set the fill price arbitrarily when backtesting (if only one could get it to work under live trading). I'm wondering if it would work to fix the problem of how the backtester fills limit/stop orders. Under live trading, the trigger will be evaluated effectively immediately after the order is encountered in the algorithm code, whereas in backtesting (if it works how I think), the trigger is not evaluated until the next bar and if triggered, the order is submitted (and subsequently filled upon the next next bar). So, if I'm reading things correctly, when backtesting, there is way too much latency in filling compared to live trading.

On a separate note, you might be interested in https://www.quantopian.com/posts/finite-state-machine-in-python (Ed Bartosh provides a nice example).

Grant