Backtesting an OLMAR Portfolio and Reviewing It with Pyfolio
Summary
This notebook demonstrates a workflow for running an online portfolio moving average reversion algorithm in Zipline and analyzing its output with pyfolio. The example applies OLMAR to a fixed basket of seven stocks, estimates relative mean deviations from a five-day price history, adjusts portfolio weights according to a threshold parameter, and projects the resulting weights onto the nonnegative unit simplex. It then rebalances to target percentages and extracts returns, positions, and transactions from the backtest.
For evaluation, the notebook plots the top drawdown periods and generates a full tear sheet, optionally hiding position details when sharing results. The code sets commission and slippage to zero, so the example does not demonstrate realistic trading costs. Although the notebook contains output figures, the text provides no performance figures or interpretation of them, and the chosen live-start date is described as arbitrary. It is a practical illustration of backtest reporting rather than evidence that OLMAR is profitable or robust; the strategy and asset universe are examples that require independent testing.
Key ideas
- The notebook runs an OLMAR mean-reversion portfolio strategy in Zipline on a fixed stock basket.
- It updates weights using relative moving-average deviations and projects them to nonnegative weights that sum to one.
- Pyfolio extracts backtest data and produces drawdown plots and a full tear sheet.
- The example sets trading costs to zero and reports no interpreted performance results.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.