Reviewing the key Zipline API reference
In this section, we will outline the key features from https://www.zipline.io/appendix.html.
For backtesting, the most important features are order types, commission models, and slippage models. Let's look at them in more detail.
Types of orders
Zipline supports these types of orders:
The order-placing logic is typically placed in the handle_data
method.
The following is an example:
def handle_data(context, data): Â Â Â Â price_hist = data.history(context.stock, "close", Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â context.rolling_window, "1d") Â Â Â Â order_target_percent(context.stock, 1.0 if price_hist[-1] > price_hist.mean() else 0.0)
This example places an...