Preparing Zipline backtest results for Pyfolio Reloaded
In Chapter 7, Event-Based Backtesting Factor Portfolios with Zipline Reloaded, we learned how to use Zipline Reloaded to backtest a factor strategy. The output of a Zipline Reloaded backtest includes a DataFrame that details various metrics calculated over the backtest period, such as returns, alpha, beta, the Sharpe ratio, and drawdowns. It also provides transaction logs that capture executed orders, including asset, price, and quantity, giving insights into the trading behavior of the strategy. Additionally, Zipline Reloaded outputs an asset-wise breakdown of the portfolio, detailing the holdings and their respective values, which can be vital for risk assessment and position sizing in the portfolio.
Before we can use the DataFrame, there is some required data preprocessing. Helpfully, Pyfolio Reloaded comes with helper functions that do most of the work for us. In this recipe, we’ll read in the DataFrame and prepare...