Trend-Following Signals, Volatility Scaling, and Strategy Performance Metrics
Summary
This Python module provides utilities for evaluating systematic strategies and constructing several trend signals. It computes annual return and volatility, Sharpe and Sortino ratios, downside risk, maximum drawdown, Calmar ratio, positive-return frequency, and profit-to-loss ratio. It also supports yearly Sharpe calculations and net-return estimates after transaction costs. For position scaling, it estimates daily volatility with an exponentially weighted standard deviation, annualizes it, and targets a stated annual volatility of 15 percent.
The intermediate trend strategy blends the signs of 21-day and 252-day returns, with a weight controlling the mix, and applies the resulting direction to next-day returns. A separate MACD approach averages normalized signals across several short and long timescale pairs, with a nonlinear signal scaling function. The code is an implementation reference, not evidence of profitability. Its comments flag an omitted initial transaction cost, and the excerpt does not specify data handling, execution assumptions, or robustness checks; these choices can materially affect reported results.
Key ideas
- The module reports risk and return metrics, including Sharpe, Sortino, drawdown, and Calmar measures.
- It estimates volatility with an exponentially weighted standard deviation and scales returns toward a 15 percent annual target.
- The intermediate trend signal combines the directions of 21-day and 252-day returns.
- The MACD signal averages normalized short-versus-long exponential-average spreads across multiple timescales.
- Net-return estimates subtract transaction costs based on changes in scaled positions, though the initial cost is omitted.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.