(credit attribution: https://cssanalytics.wordpress.com/2017/11/15/adaptive-volatility/)
Aim: Get a better position sizing than [target_vol / realized_vol_{t-1}], using a more 'adaptive' volatility that varies its lookback period according to market conditions.
The simplest method is to use the R-squared of the regression of prices vs time:
1. high R-squared indicates a trending market -> use short lookback periods
2. low R-squared instead implies a mean-reverting market -> lengthen lookback periods.
Such a R_squared value is translated into the alpha of an EMA using an exponential function (see code).
Hence the (theorical) daily exposure is:
target_vol / sqrt( EMA_{t-1}(squared rturns, alpha_t) * 252)
To limit excessive trading, rebalacing happens only if theoretical exposure above a certain threshold (say 5%).
Concept here shown for a simple static portfolio of two ETFs: SPY and TLT.
A more interesting use of this position sizing scheme is when using algorithms with long periodical rebalacings, say monthly or quarterly.